# See the License for the specific language governing permissions and
# limitations under the License.
-# Highliting of Nit AST
+# Highlighting of Nit AST
module highlight
import frontend
# Used to have a really huge and verbose HTML (mainly for debug)
var with_ast = false is writable
+ # Prefixes used in generated IDs for line `<span>` elements.
+ # Useful if more than one highlighted code is present in the same HTML document.
+ #
+ # If set to the empty string, id for lines are disabled.
+ #
+ # Is `"L"` by default.
+ var line_id_prefix = "L" is writable
+
# The first line to generate, null if start at the first line
var first_line: nullable Int = null is writable
html.add_class("nitcode")
end
+ # The entry-point of the highlighting.
+ # Will fill `html` with the generated HTML content.
fun enter_visit(n: ANode)
do
n.parentize_tokens
# Add a div for the whole line
var tag = new HTMLTag("span")
- tag.attrs["id"] = "L{cline}"
+ var p = line_id_prefix
+ if p != "" then tag.attrs["id"] = "{p}{cline}"
tag.classes.add "line"
stack2.add(html)
html.add tag
return res
end
+ # The module HTML page
fun href: String
do
return name + ".html"
return res
end
+ # The class HTML page (an anchor in the module page)
fun href: String
do
return mmodule.href + "#" + to_s
return res
end
+ # The property HTML page (an anchor in the module page)
fun href: String
do
return self.mclassdef.mmodule.href + "#" + self.to_s