Slanted font
This commit is contained in:
parent
62263fbe0f
commit
37c8ec4e2e
5 changed files with 26 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
from panflute import Quoted
|
||||
from panflute import Quoted, Emph
|
||||
|
||||
|
||||
from .command import Command, InlineCommand, BlockCommand, CodeCommand
|
||||
|
@ -14,3 +14,5 @@ class FQuoted(Quoted):
|
|||
del kwargs["style"]
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
class Slanted(Emph):
|
||||
pass
|
||||
|
|
|
@ -6,7 +6,7 @@ from panflute import MetaValue
|
|||
from typing import Union, Callable
|
||||
|
||||
from .whitespace import NBSP
|
||||
from .elements import FQuoted
|
||||
from .elements import FQuoted, Slanted
|
||||
from .context import Group, InlineGroup, BlockGroup, Context
|
||||
from .whitespace import Whitespace
|
||||
from .command import BlockCommand, InlineCommand, CodeCommand, Command
|
||||
|
@ -69,6 +69,7 @@ class NOPProcessor:
|
|||
Cite: self.transform_Cite,
|
||||
Code: self.transform_Code,
|
||||
Emph: self.transform_Emph,
|
||||
Slanted: self.transform_Slanted,
|
||||
Image: self.transform_Image,
|
||||
LineBreak: self.transform_LineBreak,
|
||||
Link: self.transform_Link,
|
||||
|
@ -263,6 +264,10 @@ class NOPProcessor:
|
|||
e.content = self.transform(e.content)
|
||||
return e
|
||||
|
||||
def transform_Slanted(self, e: Slanted) -> Slanted:
|
||||
e.content = self.transform(e.content)
|
||||
return e
|
||||
|
||||
def transform_Link(self, e: Link) -> Link:
|
||||
e.content = self.transform(e.content)
|
||||
return e
|
||||
|
|
|
@ -7,7 +7,7 @@ from panflute import stringify
|
|||
from typing import Union, Callable
|
||||
|
||||
from .whitespace import NBSP
|
||||
from .elements import FQuoted
|
||||
from .elements import FQuoted, Slanted
|
||||
from .context import Group, InlineGroup, BlockGroup, Context
|
||||
|
||||
|
||||
|
@ -108,6 +108,7 @@ class OutputGenerator:
|
|||
Cite: self.generate_Cite,
|
||||
Code: self.generate_Code,
|
||||
Emph: self.generate_Emph,
|
||||
Slanted: self.generate_Slanted,
|
||||
Image: self.generate_Image,
|
||||
LineBreak: self.generate_LineBreak,
|
||||
Link: self.generate_Link,
|
||||
|
@ -376,6 +377,9 @@ class OutputGenerator:
|
|||
def generate_Emph(self, e: Emph):
|
||||
self.generate_simple_tag(e)
|
||||
|
||||
def generate_Slanted(self, e: Slanted):
|
||||
self.generate_Emph(e)
|
||||
|
||||
def generate_Image(self, e: Image):
|
||||
self.generate_simple_tag(e)
|
||||
|
||||
|
|
|
@ -179,6 +179,11 @@ class UCWTexGenerator(OutputGenerator):
|
|||
self._italic-=1
|
||||
self.write(r"}")
|
||||
|
||||
def generate_Slanted(self, e: Emph):
|
||||
self.write(r"{\sl{}")
|
||||
self.generate(e.content)
|
||||
self.write(r"}")
|
||||
|
||||
def generate_Strong(self, e: Strong):
|
||||
if self._italic > 0:
|
||||
self.write(r"{\bi{}")
|
||||
|
|
|
@ -14,7 +14,7 @@ import importlib
|
|||
import json
|
||||
|
||||
from .whitespace import NBSP
|
||||
from .elements import FQuoted
|
||||
from .elements import FQuoted, Slanted
|
||||
from .context import Group, InlineGroup, BlockGroup
|
||||
from .util import nullify, import_md
|
||||
from .context import Context, CommandCallable
|
||||
|
@ -262,6 +262,12 @@ class TransformProcessor(NOPProcessor):
|
|||
raise TypeError(f"Cannot print value of metadatum '{e.content[0].text[1:]}' of type '{type(val)}'")
|
||||
return e
|
||||
|
||||
if "slanted" in e.classes:
|
||||
# `.slanted` class for Span
|
||||
# Content of Span is enclosed into Slanted (subclass os Emph)
|
||||
return self.transform(Slanted(*e.content))
|
||||
|
||||
|
||||
return e
|
||||
|
||||
def transform_CodeBlock(self, e: CodeBlock) -> Union[CodeBlock, Div, Null]:
|
||||
|
|
Loading…
Reference in a new issue