diff --git a/ly/cli/command.py b/ly/cli/command.py index 3fb0ba49..075b77ef 100644 --- a/ly/cli/command.py +++ b/ly/cli/command.py @@ -225,11 +225,16 @@ def run(self, opts, cursor, output): import ly.colorize w = ly.colorize.HtmlWriter() + w.full_html = opts.full_html w.inline_style = opts.inline_style w.stylesheet_ref = opts.stylesheet w.number_lines = opts.number_lines w.title = cursor.document.filename w.encoding = opts.output_encoding or "utf-8" + w.wrapper_tag = opts.wrapper_tag + w.wrapper_attribute = opts.wrapper_attribute + w.document_id = opts.document_id + w.linenumbers_id = opts.linenumbers_id doc = w.html(cursor) if self.output: diff --git a/ly/cli/doc.py b/ly/cli/doc.py index e63af30a..2fa52af2 100644 --- a/ly/cli/doc.py +++ b/ly/cli/doc.py @@ -163,6 +163,11 @@ ``indent-width`` [2] how many spaces for each indent level (if not using tabs) + ``full-html`` [``True``] + if set to True a full document with syntax-highlighted HTML + will be exported, otherwise only the bare content wrapped in an + element configured by the ``wrapper-`` variables. + ``stylesheet`` filename to reference as an external stylesheet for syntax-highlighted HTML. This filename is literally used @@ -175,6 +180,22 @@ ``number-lines`` [``false``] whether to add line numbers when creating syntax-highlighted HTML. + ``wrapper-tag`` [``pre``] + which tag syntax highlighted HTML will be wrapped in. Possible values: + ``div``, ``pre``, ``id`` and ``code`` + + ``wrapper-attribute`` [``class``] + attribute used for the wrapper tag. Possible values: ``id`` and ``class``. + + ``document-id`` [``lilypond``] + name applied to the wrapper-attribute. + If the three last options use their default settings + the highlighted HTML elements are wrapped in an element + ``
``
+
+  ``linenumbers-id`` [``linenumbers``]
+        if linenumbers are exported this is the name used for the ```` elements
+
 These variables influence the output of information commands:
 
   ``with-filename``
diff --git a/ly/cli/main.py b/ly/cli/main.py
index 627b8206..82d52a3b 100644
--- a/ly/cli/main.py
+++ b/ly/cli/main.py
@@ -77,10 +77,15 @@ def __init__(self):
         self.indent_tabs = False
         self.tab_width = 8
         
+        self.full_html = True
         self.inline_style = False
         self.stylesheet = None
         self.number_lines = False
-    
+        self.wrapper_tag = 'pre'
+        self.wrapper_attribute = 'class'
+        self.document_id = 'lilypond'
+        self.linenumbers_id = 'linenumbers'
+
     def set_variable(self, name, value):
         name = name.replace('-', '_')
         try:
diff --git a/ly/cli/setvar.py b/ly/cli/setvar.py
index f677b5cc..63d466dc 100644
--- a/ly/cli/setvar.py
+++ b/ly/cli/setvar.py
@@ -123,6 +123,10 @@ def inline_style(arg):
     return _check_bool("inline-style", arg)
 
 
+def full_html(arg):
+    return _check_bool("full_html", arg)
+
+
 def stylesheet(arg):
     return arg or None
 
@@ -131,3 +135,23 @@ def number_lines(arg):
     return _check_bool("number-lines", arg)
 
 
+def wrapper_tag(arg):
+    if not arg in ['div', 'pre', 'code', 'id']:
+        raise ValueError("unknown wrapper tag: {tag}".format(
+            tag=arg))
+    return arg
+
+
+def wrapper_attribute(arg):
+    if not arg in ['id', 'class']:
+        raise ValueError("wrapper attribute must be 'id' or 'class', found {attr}".format(
+            attr=arg))
+    return arg
+
+    
+def document_id(arg):
+    return arg or None
+
+
+def linenumbers_id(arg):
+    return arg or None