FLineMarkup
This commit is contained in:
parent
8bcb087979
commit
4e2ea4173e
4 changed files with 37 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
from panflute import Quoted, Emph, Link
|
from panflute import Quoted, Emph, Link, Div
|
||||||
|
|
||||||
|
|
||||||
from .command import Command, InlineCommand, BlockCommand, CodeCommand
|
from .command import Command, InlineCommand, BlockCommand, CodeCommand
|
||||||
|
@ -26,3 +26,10 @@ class FLink(Link):
|
||||||
|
|
||||||
class FileLink(Link):
|
class FileLink(Link):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class FLineMarkup(Div):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.color = kwargs["color"]
|
||||||
|
del kwargs["color"]
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ from panflute import stringify
|
||||||
from typing import Union, Callable
|
from typing import Union, Callable
|
||||||
|
|
||||||
from .whitespace import NBSP
|
from .whitespace import NBSP
|
||||||
from .elements import FQuoted, Slanted, FLink, FileLink
|
from .elements import FQuoted, Slanted, FLink, FileLink, FLineMarkup
|
||||||
from .context import Group, InlineGroup, BlockGroup, Context
|
from .context import Group, InlineGroup, BlockGroup, Context
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ class OutputGenerator:
|
||||||
DefinitionItem: self.generate_DefinitionItem,
|
DefinitionItem: self.generate_DefinitionItem,
|
||||||
DefinitionList: self.generate_DefinitionList,
|
DefinitionList: self.generate_DefinitionList,
|
||||||
Div: self.generate_Div,
|
Div: self.generate_Div,
|
||||||
|
FLineMarkup: self.generate_FLineMarkup,
|
||||||
Figure: self.generate_Figure,
|
Figure: self.generate_Figure,
|
||||||
Header: self.generate_Header,
|
Header: self.generate_Header,
|
||||||
HorizontalRule: self.generate_HorizontalRule,
|
HorizontalRule: self.generate_HorizontalRule,
|
||||||
|
@ -462,6 +463,9 @@ class OutputGenerator:
|
||||||
def generate_Div(self, e: Div):
|
def generate_Div(self, e: Div):
|
||||||
self.generate_simple_tag(e)
|
self.generate_simple_tag(e)
|
||||||
|
|
||||||
|
def generate_FLineMarkup(self, e: FLineMarkup):
|
||||||
|
self.generate_Div(e)
|
||||||
|
|
||||||
def generate_Header(self, e: Header):
|
def generate_Header(self, e: Header):
|
||||||
self.generate_simple_tag(e)
|
self.generate_simple_tag(e)
|
||||||
|
|
||||||
|
|
|
@ -63,3 +63,12 @@
|
||||||
\cleaders\hbox{$\mkern-2mu\smash-\mkern-2mu$}\hfill
|
\cleaders\hbox{$\mkern-2mu\smash-\mkern-2mu$}\hfill
|
||||||
\settextsize{5}\mkern-7mu\mathord\rightarrow$}
|
\settextsize{5}\mkern-7mu\mathord\rightarrow$}
|
||||||
\catcode`@=12
|
\catcode`@=12
|
||||||
|
|
||||||
|
|
||||||
|
\long\def\linemarkup#1#2{%
|
||||||
|
\par\noindent\hbox{%
|
||||||
|
\hbox{}\hskip -6pt {\colorlocal{#1}\vrule width 1pt \hskip 5pt}%
|
||||||
|
\hbox to \hsize{\vbox{#2}\hfil}%
|
||||||
|
%\hbox{}\hskip 5pt {\colorlocal{#1}\vrule width 1pt \hskip -6pt}%
|
||||||
|
}\par%
|
||||||
|
}
|
||||||
|
|
|
@ -11,10 +11,14 @@ from .output_generator import OutputGenerator
|
||||||
from .images import ImageProcessor, ImageProcessorNamespaceSearcher
|
from .images import ImageProcessor, ImageProcessorNamespaceSearcher
|
||||||
|
|
||||||
from .whitespace import NBSP
|
from .whitespace import NBSP
|
||||||
from .elements import FQuoted
|
from .elements import FQuoted, FLineMarkup
|
||||||
from .context import Group, InlineGroup, BlockGroup, Context
|
from .context import Group, InlineGroup, BlockGroup, Context
|
||||||
from .util import inlinify
|
from .util import inlinify
|
||||||
|
|
||||||
|
def color_to_rgb(color):
|
||||||
|
import matplotlib.colors
|
||||||
|
return matplotlib.colors.to_rgb(color)
|
||||||
|
|
||||||
class UCWTexGenerator(OutputGenerator):
|
class UCWTexGenerator(OutputGenerator):
|
||||||
imageProcessor: ImageProcessor
|
imageProcessor: ImageProcessor
|
||||||
_bold: int
|
_bold: int
|
||||||
|
@ -296,6 +300,16 @@ class UCWTexGenerator(OutputGenerator):
|
||||||
|
|
||||||
def generate_Div(self, e: Div):
|
def generate_Div(self, e: Div):
|
||||||
self.generate(e.content)
|
self.generate(e.content)
|
||||||
|
|
||||||
|
def generate_FLineMarkup(self, e: FLineMarkup):
|
||||||
|
self.ensure_empty(2)
|
||||||
|
r,g,b = color_to_rgb(e.color)
|
||||||
|
self.writeln(r"\linemarkup{\rgb{"+f"{r} {g} {b}"+"}}{")
|
||||||
|
self.indent_more()
|
||||||
|
self.generate(e.content)
|
||||||
|
self.indent_less()
|
||||||
|
self.writeln(r"}")
|
||||||
|
self.ensure_empty(2)
|
||||||
|
|
||||||
def generate_LineBlock(self, e: LineBlock):
|
def generate_LineBlock(self, e: LineBlock):
|
||||||
self.writeln()
|
self.writeln()
|
||||||
|
|
Loading…
Reference in a new issue