Add markup rendering and basic styling.

This commit is contained in:
Sergio Martínez Portela 2022-12-28 22:42:26 +01:00
parent f174be032e
commit 90d1c15ba7
2 changed files with 23 additions and 4 deletions

View File

@ -601,8 +601,22 @@ def render_text_tokens(tokens, acc, headline, graph):
except NonExistingLocalNoteError as err: except NonExistingLocalNoteError as err:
logging.warning(err.get_message()) logging.warning(err.get_message())
acc.append(html.escape(description)) acc.append(html.escape(description))
# else: elif isinstance(chunk, org_rw.MarkerToken):
# raise NotImplementedError('TextToken: {}'.format(chunk)) tag = '<'
if chunk.closing:
tag += '/'
tag += {
org_rw.MarkerType.BOLD_MODE: 'strong',
org_rw.MarkerType.CODE_MODE: 'code',
org_rw.MarkerType.ITALIC_MODE: 'em',
org_rw.MarkerType.STRIKE_MODE: 's',
org_rw.MarkerType.UNDERLINED_MODE: 'span class="underlined"' if not chunk.closing else 'span',
org_rw.MarkerType.VERBATIM_MODE: 'span class="verbatim"' if not chunk.closing else 'span',
}[chunk.tok_type]
tag += '>'
acc.append(tag)
else:
raise NotImplementedError('TextToken: {}'.format(chunk))
acc.append('</p>') acc.append('</p>')

View File

@ -340,6 +340,11 @@ a.internal::after {
content: ' }'; content: ' }';
} }
/* Markup */
.underlined {
text-decoration: underline;
}
/* Code blocks */ /* Code blocks */
pre { pre {
overflow: auto; overflow: auto;
@ -366,7 +371,7 @@ pre code {
padding: 0.5ex; padding: 0.5ex;
} }
code { code, .verbatim {
padding: 0.25ex 0.5ex; padding: 0.25ex 0.5ex;
margin: 0.25ex; margin: 0.25ex;
background: #eee; background: #eee;
@ -542,7 +547,7 @@ tr.__table-separator {
color: #fff; color: #fff;
} }
code { code, .verbatim {
background: #262826; background: #262826;
color: #FFF; color: #FFF;
font-family: Menlo, Monaco, "Courier New", monospace; font-family: Menlo, Monaco, "Courier New", monospace;