Browse Source

Merge remote-tracking branch 'origin/master' into jk-bakalarka

jk-bakalarka
Jiří Kalvoda 9 months ago
parent
commit
a2468b54e1
  1. 2
      src/formatitko/katex-server
  2. 9
      src/formatitko/transform_processor.py
  3. 6
      src/formatitko/whitespace.py

2
src/formatitko/katex-server

@ -1 +1 @@
Subproject commit 953b44e942282375ac369af233c123b28146713e Subproject commit 211cb2010e23265be599819c5f79f66f0abd62d1

9
src/formatitko/transform_processor.py

@ -131,7 +131,6 @@ class TransformProcessor(NOPProcessor):
return super().transform_Para(e) return super().transform_Para(e)
def transform_Div(self, e: Div) -> Union[Div, Group, Null, RawBlock]: def transform_Div(self, e: Div) -> Union[Div, Group, Null, RawBlock]:
e.content = self.transform(e.content)
if "group" in e.classes: if "group" in e.classes:
# `.group` class for Divs # `.group` class for Divs
@ -191,10 +190,9 @@ class TransformProcessor(NOPProcessor):
if "lang" in e.attributes: if "lang" in e.attributes:
warnings.warn("To set language in a way formátítko will understand, this Div has to have the `.group` class and be a Group.", UserWarning) warnings.warn("To set language in a way formátítko will understand, this Div has to have the `.group` class and be a Group.", UserWarning)
return e return super().transform_Div(e)
def transform_Span(self, e: Span) -> Span: def transform_Span(self, e: Span) -> Span:
e.content = self.transform(e.content)
if "group" in e.classes: if "group" in e.classes:
# `.group` class for Spans # `.group` class for Spans
@ -251,7 +249,7 @@ class TransformProcessor(NOPProcessor):
# This is a shorthand for just printing the content of some metadata. # This is a shorthand for just printing the content of some metadata.
elif re.match(r"^\$[\w.]+$", e.content[0].text): elif re.match(r"^\$[\w.]+$", e.content[0].text):
val = self.context.get_metadata(e.content[0].text[1:], False) val = self.context.get_metadata(e.content[0].text[1:], False)
if isinstance(val, MetaInlines): if isinstance(val, MetaInlines): # TODO: Trust transform for this
e = Span(*val.content) e = Span(*val.content)
e = self.transform(e) e = self.transform(e)
elif isinstance(val, MetaString): elif isinstance(val, MetaString):
@ -267,8 +265,7 @@ class TransformProcessor(NOPProcessor):
# Content of Span is enclosed into Slanted (subclass os Emph) # Content of Span is enclosed into Slanted (subclass os Emph)
return self.transform(Slanted(*e.content)) return self.transform(Slanted(*e.content))
return super().transform_Span(e)
return e
def transform_CodeBlock(self, e: CodeBlock) -> Union[CodeBlock, Div, Null]: def transform_CodeBlock(self, e: CodeBlock) -> Union[CodeBlock, Div, Null]:
if "markdown" in e.classes and "group" in e.classes: if "markdown" in e.classes and "group" in e.classes:

6
src/formatitko/whitespace.py

@ -36,9 +36,9 @@ def bavlna(e: Whitespace, c: Context) -> bool:
if prevC in operators and nextC in numbers: if prevC in operators and nextC in numbers:
return True return True
if isinstance(e.prev, Math) or isinstance(e.next, Math): # if isinstance(e.prev, Math) or isinstance(e.next, Math):
# Add no-break spaces around TeX math. # # Add no-break spaces around TeX math.
return True # return True

Loading…
Cancel
Save