Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ly/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions ly/cli/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
``<pre class="lilypond"></pre>``

``linenumbers-id`` [``linenumbers``]
if linenumbers are exported this is the name used for the ``<td>`` elements

These variables influence the output of information commands:

``with-filename``
Expand Down
7 changes: 6 additions & 1 deletion ly/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions ly/cli/setvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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