mirror of https://github.com/Nonannet/pyladoc.git
Compare commits
5 Commits
3098226c75
...
13c2aaac8b
Author | SHA1 | Date |
---|---|---|
|
13c2aaac8b | |
|
4c396cd5b3 | |
|
c7123e23d9 | |
|
df592aef6a | |
|
65b9a300b9 |
|
@ -103,7 +103,7 @@ jobs:
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
id: miktex
|
id: miktex
|
||||||
with:
|
with:
|
||||||
path: miktex-portable
|
path: C:\tmp\cache
|
||||||
key: miktex-portable-${{ runner.os }}-24.1-x64
|
key: miktex-portable-${{ runner.os }}-24.1-x64
|
||||||
|
|
||||||
- if: ${{ steps.miktex.outputs.cache-hit != 'true' }}
|
- if: ${{ steps.miktex.outputs.cache-hit != 'true' }}
|
||||||
|
@ -111,11 +111,11 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
$ProgressPreference = 'SilentlyContinue'
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
Invoke-WebRequest https://www.nonan.net/w/files/miktex-portable-Win-x64.zip -OutFile miktex-portable-Win-x64.zip
|
Invoke-WebRequest https://www.nonan.net/w/files/miktex-portable-Win-x64.zip -OutFile miktex-portable-Win-x64.zip
|
||||||
Expand-Archive miktex-portable-Win-x64.zip -DestinationPath .
|
Expand-Archive miktex-portable-Win-x64.zip -DestinationPath C:\tmp\cache\
|
||||||
|
|
||||||
- name: Copy miktex directory
|
- name: Copy miktex directory
|
||||||
run: |
|
run: |
|
||||||
robocopy miktex-portable C:\tmp\test_miktex\miktex-portable /E /NFL /NDL
|
robocopy C:\tmp\cache\miktex-portable C:\tmp\test_miktex\miktex-portable /E /NFL /NDL
|
||||||
if ($LASTEXITCODE -eq 1) { exit 0 }
|
if ($LASTEXITCODE -eq 1) { exit 0 }
|
||||||
|
|
||||||
- name: Add miktex to PATH
|
- name: Add miktex to PATH
|
||||||
|
@ -140,6 +140,7 @@ jobs:
|
||||||
path: tests/out/test_*_render*.pdf
|
path: tests/out/test_*_render*.pdf
|
||||||
|
|
||||||
build-docs:
|
build-docs:
|
||||||
|
if: github.event_name == 'push'
|
||||||
needs: build-ubuntu
|
needs: build-ubuntu
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
@ -183,6 +184,7 @@ jobs:
|
||||||
path: docs/build/html
|
path: docs/build/html
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
|
if: github.event_name == 'push'
|
||||||
needs: build-docs
|
needs: build-docs
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
|
|
|
@ -621,7 +621,7 @@ class DocumentWriter():
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
text: The markdown text to add
|
text: The markdown text to add
|
||||||
section_class: The class for the text section
|
section_class: The HTML-class and LaTeX-environment name for the text section
|
||||||
"""
|
"""
|
||||||
norm_text = _normalize_text_indent(str(text))
|
norm_text = _normalize_text_indent(str(text))
|
||||||
|
|
||||||
|
@ -633,8 +633,7 @@ class DocumentWriter():
|
||||||
return html
|
return html
|
||||||
|
|
||||||
def render_to_latex() -> str:
|
def render_to_latex() -> str:
|
||||||
html = _markdown_to_html(
|
html = render_to_html()
|
||||||
self._equation_embedding_reescaping(norm_text))
|
|
||||||
return latex.from_html(html)
|
return latex.from_html(html)
|
||||||
|
|
||||||
self._doc.append([render_to_html, render_to_latex])
|
self._doc.append([render_to_html, render_to_latex])
|
||||||
|
|
|
@ -191,6 +191,7 @@ def from_html(html_code: str) -> str:
|
||||||
self.header_flag = False
|
self.header_flag = False
|
||||||
self.attr_dict: dict[str, str] = {}
|
self.attr_dict: dict[str, str] = {}
|
||||||
self.equation_flag = False
|
self.equation_flag = False
|
||||||
|
self.class_name: str = ''
|
||||||
|
|
||||||
def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None:
|
def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None:
|
||||||
self.attr_dict = {k: v if v else '' for k, v in attrs}
|
self.attr_dict = {k: v if v else '' for k, v in attrs}
|
||||||
|
@ -217,6 +218,10 @@ def from_html(html_code: str) -> str:
|
||||||
self.latex_code.append("\n\n\\noindent\\rule[0.5ex]{\\linewidth}{1pt}\n\n")
|
self.latex_code.append("\n\n\\noindent\\rule[0.5ex]{\\linewidth}{1pt}\n\n")
|
||||||
elif tag == 'latex':
|
elif tag == 'latex':
|
||||||
self.equation_flag = True
|
self.equation_flag = True
|
||||||
|
elif tag == 'div':
|
||||||
|
self.class_name = self.attr_dict.get('class', '')
|
||||||
|
if self.class_name:
|
||||||
|
self.latex_code.append(f"\n\\begin{{{self.class_name}}}\n")
|
||||||
|
|
||||||
def handle_endtag(self, tag: str) -> None:
|
def handle_endtag(self, tag: str) -> None:
|
||||||
if tag in html_to_latex:
|
if tag in html_to_latex:
|
||||||
|
@ -242,6 +247,9 @@ def from_html(html_code: str) -> str:
|
||||||
self.latex_code.append("}")
|
self.latex_code.append("}")
|
||||||
elif tag == 'latex':
|
elif tag == 'latex':
|
||||||
self.equation_flag = False
|
self.equation_flag = False
|
||||||
|
elif tag == 'div':
|
||||||
|
if self.class_name:
|
||||||
|
self.latex_code.append(f"\n\\end{{{self.class_name}}}\n")
|
||||||
|
|
||||||
def handle_data(self, data: str) -> None:
|
def handle_data(self, data: str) -> None:
|
||||||
if self.equation_flag:
|
if self.equation_flag:
|
||||||
|
|
|
@ -16,11 +16,17 @@
|
||||||
\usepackage{booktabs} % For professional-looking tables
|
\usepackage{booktabs} % For professional-looking tables
|
||||||
\usepackage{pgf} % For using pgf grafics
|
\usepackage{pgf} % For using pgf grafics
|
||||||
\usepackage{textcomp, gensymb} % provides \degree symbol
|
\usepackage{textcomp, gensymb} % provides \degree symbol
|
||||||
|
\usepackage{xcolor} % For colored text
|
||||||
|
|
||||||
\sisetup{
|
\sisetup{
|
||||||
table-align-text-post = false
|
table-align-text-post = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
% Define fine print environment
|
||||||
|
\newenvironment{fineprint}
|
||||||
|
{\par\vspace{0.5\baselineskip}\noindent\footnotesize\color{gray}}
|
||||||
|
{\par\vspace{0.5\baselineskip}}
|
||||||
|
|
||||||
% Geometry Settings
|
% Geometry Settings
|
||||||
\geometry{margin=1in} % 1-inch margins
|
\geometry{margin=1in} % 1-inch margins
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,12 @@
|
||||||
padding-bottom: 50px;
|
padding-bottom: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.fineprint
|
||||||
|
{
|
||||||
|
font-size: smaller;
|
||||||
|
color: grey;
|
||||||
|
}
|
||||||
|
|
||||||
div h1
|
div h1
|
||||||
{
|
{
|
||||||
font-size: 32px;
|
font-size: 32px;
|
||||||
|
|
|
@ -81,6 +81,13 @@ def make_document():
|
||||||
|
|
||||||
doc.add_table(df.style.hide(axis="index"), 'This is a example table', 'example1')
|
doc.add_table(df.style.hide(axis="index"), 'This is a example table', 'example1')
|
||||||
|
|
||||||
|
doc.add_text("This is a fine print test text section. It uses smaller text and uses grey color. This is a fine print test"
|
||||||
|
"text section. It uses smaller text and uses grey color.", section_class='fineprint')
|
||||||
|
|
||||||
|
doc.add_text("Standard text section. This is normal text without any special formatting. It uses the default text size and color.")
|
||||||
|
|
||||||
|
doc.add_markdown("This is a **fine print** test text section. It uses **smaller text** and uses **grey** color.", section_class='fineprint')
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue