rinohtype icon indicating copy to clipboard operation
rinohtype copied to clipboard

Examples are outdated

Open madum31 opened this issue 4 months ago • 3 comments

Hi Brecht and support team,

First, I really like this way of generating PDF documents. With rinohtype 0.5.5, I'm trying to run the test.py file present in examples/restructuredtext, but the python output gives :

Traceback (most recent call last): File "C:\Temp\rinohtype-master\examples\restructuredtext\test.py", line 3, in < module > from rinoh.structure import AdmonitionTitles ImportError: cannot import name 'AdmonitionTitles' from 'rinoh.structure'

I suppose, this should run with an old rinohtype version. I'm I right ? I tried to update the test.py file with AdmonitionStyle rather than AdmonitionTitles but get new issues running it. Which rinohtype package version do I use to run the examples/restructuredtext/test.py ?

Thanks for your help, best regards, Martial

madum31 avatar Aug 29 '25 13:08 madum31

The examples are horribly out of date, I'm afraid. Thank you bringing this to my attention. I gave it a quick shot to get the reStructuredText example running again. It renders demo.txt but fails on the other documents...

test.py

from pathlib import Path

from rinoh.frontend.rst import ReStructuredTextReader
from rinoh.style import StyleSheet
from rinoh.template import TemplateConfigurationFile


DIR = Path(__file__).parent


if __name__ == '__main__':
    default_stylesheet = StyleSheet('empty')
    default_stylesheet.write('emtpy')

    configuration = TemplateConfigurationFile(DIR / 'article.rtt')

    sphinx_stylesheet = configuration['stylesheet'].base
    sphinx_stylesheet.write('sphinx')   # test writing an .rts stylesheet

    for name in ('demo', 'quickstart', 'FAQ', 'THANKS'):
        parser = ReStructuredTextReader()
        document_tree = parser.parse(name + '.txt')
        document = configuration.document(document_tree)
        document.render(name)

article.rtt

[TEMPLATE_CONFIGURATION]
name=
template=article
description=

;parts =
;    title
;    front_matter
;    contents
stylesheet=sphinx_article
;table_of_contents=false
abstract_location=title

[STRINGS]
@important = 'IMPORTANT:'
@tip = 'TIP:'


[VARIABLES]
paper_size=A4

; [title]
; page_number_format=number
; end_at_page=left

; [front_matter]
; page_number_format=lowercase roman
; end_at_page=left

[contents]
page_number_format=number
end_at_page=any

[page]
page_size=$(paper_size)
left_margin=1in
right_margin=1in
top_margin=1in
bottom_margin=1in
;chapter_title_flowables=none

; [title_page]
; base=page
; top_margin=2cm

; [front_matter_page]
; base=page

[contents_page]
footer_text = '\t{PAGE_NUMBER} of {NUMBER_OF_PAGES}'

; [contents_right_page]
; base=contents_page
; header_text='\t\t{SECTION_TITLE(1)}  {SECTION_NUMBER(1)}'

; [contents_left_page]
; base=contents_page
; header_text='{SECTION_NUMBER(2)}  {SECTION_TITLE(2)}'

Also see #215

brechtm avatar Aug 29 '25 21:08 brechtm

Many thanks Brecht for this quick update.

Even if running test.py reports some errors :

python test.py demo.txt:96: (ERROR/3) Undefined substitution referenced: "problematic". demo.txt:554: (ERROR/3) Undefined substitution referenced: "*** Expect 6 errors (including this one). ***". demo.txt:353: (ERROR/3) Unknown target name: "5". demo.txt:362: (ERROR/3) Unknown target name: "nonexistent". demo.txt:387: (ERROR/3) Unknown target name: "hyperlink reference without a target". demo.txt:400: (ERROR/3) Duplicate target name, cannot be used as a unique reference: "duplicate target names". rinohtype 0.5.5 (2024-07-13) Copyright (c) Brecht Machiels and contributors This program comes with ABSOLUTELY NO WARRANTY. Its use is subject to the terms of the GNU Affero General Public License version 3. TeXGyrePagella-Regular does not contain glyph for unicode index 0x326d (?) DejaVuSerif does not contain glyph for unicode index 0x326d (?) TeXGyrePagella-Regular does not contain glyph for unicode index 0x2023 (?) [demo.txt:None <system_message>] demo.txt:6: (INFO/1) Enumerated list start value not ordinal-1: "3" (ordinal 3) (page 3) [demo.txt:None <system_message>] demo.txt:6: (INFO/1) Enumerated list start value not ordinal-1: "C" (ordinal 3) (page 3) [demo.txt:None <system_message>] demo.txt:6: (INFO/1) Enumerated list start value not ordinal-1: "iii" (ordinal 3) (page 3) TeX Gyre Cursor does not include a normal medium upright font. Falling back to normal regular upright [demo.txt:398 <system_message>] demo.txt:398: (INFO/1) Duplicate implicit target name: "duplicate target names". (page 6) Tab did not fall into any of the tab stops. (page 6)00:03 (00:05) page 6 100% [========================================] ETA 00:00 (00:06) page 8 Not yet converged, rendering again... 100% [========================================] ETA 00:00 (00:03) page 8 Writing output: demo.pdf rinohtype 0.5.5 (2024-07-13) Copyright (c) Brecht Machiels and contributors This program comes with ABSOLUTELY NO WARRANTY. Its use is subject to the terms of the GNU Affero General Public License version 3. TeX Gyre Cursor does not include a normal medium upright font. Falling back to normal regular upright [quickstart.txt:None <system_message>] quickstart.txt:2: (INFO/1) Enumerated list start value not ordinal-1: "3" (ordinal 3) (page 2) 96% [====================================== ] ETA 00:00 (00:01) page 5 Not yet converged, rendering again... 96% [====================================== ] ETA 00:00 (00:01) page 5 Writing output: quickstart.pdf rinohtype 0.5.5 (2024-07-13) Copyright (c) Brecht Machiels and contributors This program comes with ABSOLUTELY NO WARRANTY. Its use is subject to the terms of the GNU Affero General Public License version 3. [FAQ.txt:62 <system_message>] FAQ.txt:62: (INFO/1) Duplicate implicit target name: "docutils". (page 2) [FAQ.txt:166 <system_message>] FAQ.txt:166: (INFO/1) Duplicate implicit target name: "restructuredtext". (page 3) TeX Gyre Cursor does not include a normal medium upright font. Falling back to normal regular upright 100% [========================================] ETA 00:00 (00:04) page 15 Not yet converged, rendering again... 100% [========================================] ETA 00:00 (00:04) page 15 Writing output: FAQ.pdf rinohtype 0.5.5 (2024-07-13) Copyright (c) Brecht Machiels and contributors This program comes with ABSOLUTELY NO WARRANTY. Its use is subject to the terms of the GNU Affero General Public License version 3. 100% [========================================] ETA 00:00 (00:02) page 4 Not yet converged, rendering again... 100% [========================================] ETA 00:00 (00:03) page 4 Writing output: THANKS.pdf

I got enough exploitable results to go further in using rinohtype 👍

best regards, Martial

madum31 avatar Aug 30 '25 10:08 madum31

The errors are normal here. They are output by docutils to inform the user about problems with the reStructuredText input. At least in demo.txt, these are part of the demonstration.

The other documents failed to build for me previously because .rtc cache files from an old version of rinohtype were still present. Ideally, I should store a version in the cache file and avoid loading incompatible ones.

brechtm avatar Aug 31 '25 13:08 brechtm