From 70196134d6a883f4da392839321fe7d3822c2409 Mon Sep 17 00:00:00 2001 From: randogoth Date: Mon, 20 Oct 2025 00:00:16 +0300 Subject: [PATCH] figlet alignment --- examples/loremipsum.md | 3 + loremipsum.txt | 121 ++++++++++++++++++++++++++++++ md2txt.py | 41 +++++++---- output.txt | 163 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 313 insertions(+), 15 deletions(-) create mode 100644 loremipsum.txt create mode 100644 output.txt diff --git a/examples/loremipsum.md b/examples/loremipsum.md index 63d5ec9..998f544 100644 --- a/examples/loremipsum.md +++ b/examples/loremipsum.md @@ -32,6 +32,7 @@ populifer adeunt quicquam cum **ales** Ixion angulus placet reddere. {:.right} ## Tractaque serpens arva quoque +{:.center} Inprudens dum memor alma, casses dedi Sinuessa iam quid adicit `gate_truncate_wave`. [Geratur de](#salientia-iungit-contra-et), insolida @@ -43,6 +44,7 @@ nervi famem. Cura pars natique velleris semel et at `printerWildcardParallel` inquit positosque comites ultra. ## Quantaque augent +{:.center} Acuti ignotis ignis, ostendit nostras terras nondum, [petit utque utero](#structa-hinc-vetitus-factum) sepulcrales, pluma reseratis Ismario. Tria @@ -69,6 +71,7 @@ sedisti](#mille-parva). ``` ### Mille parva +{:.center} **Minetur et** aurum! Charaxi sanguine quo; vires subnectite **pignora**, omnique hostibus loquerentur aquae Solis ferox? **Cum ne**, putat utar ex ad diff --git a/loremipsum.txt b/loremipsum.txt new file mode 100644 index 0000000..dcc85c3 --- /dev/null +++ b/loremipsum.txt @@ -0,0 +1,121 @@ + _____ _ _ _ _ + / ____| | (_) | | (_) + | (___ __ _| |_ ___ _ __ | |_ _ __ _ + \___ \ / _` | | |/ _ \ '_ \| __| |/ _` | + ____) | (_| | | | __/ | | | |_| | (_| | + |_____/ \__,_|_|_|\___|_| |_|\__|_|\__,_| + + + + ___ _ _ _ _ _ _ _ + / __| |_ _ _ _ _ __| |_ __ _ | |_ (_)_ _ __ __ _____| |_(_) |_ _ _ ___ + \__ \ _| '_| || / _| _/ _` | | ' \| | ' \/ _| \ V / -_) _| | _| || (_-< + |___/\__|_| \_,_\__|\__\__,_| |_||_|_|_||_\__| \_/\___|\__|_|\__|\_,_/__/ + + __ _ + / _|__ _ __| |_ _ _ _ __ + | _/ _` / _| _| || | ' \ + |_| \__,_\__|\__|\_,_|_|_|_| + + +Lorem markdownum omnes tellus, in, Herculeis `reciprocalPower` neque promissa e- +st Latiae caput umero talia fidissima, nymphae. Foedera et sagittas tenetur adde +matri esse: talia manibus. + + + ___ _ _ _ _ _ _ + | __| _(_) |_ __ _(_)__| |___ ___ | |___ _ _ __ _(_)__ _ _ _ ___ + | _| || | | _| \ V / / _` / -_) _ \ | / _ \ ' \/ _` | / _` | || / -_) + |_| \_,_|_|\__| \_/|_\__,_\___\___/ |_\___/_||_\__, |_\__, |\_,_\___| + |___/ |_| + _ _ _ + __| |___ __| (_)______ ___ + / _` / -_) _` | (_-<_- None: + if not block: + return + trimmed = [entry.rstrip("\n").rstrip() for entry in block] + block_width = max((len(line) for line in trimmed), default=0) + extra_space = max(0, available_width - block_width) + if style.align == "center": + align_offset = extra_space // 2 + elif style.align == "right": + align_offset = extra_space + else: + align_offset = 0 + max_indent = max(0, self.width - block_width) + indent = min(margin_left + align_offset, max_indent) + indent_str = " " * indent + for line in trimmed: + result.append(indent_str + line) + block.clear() + for line in lines: - if not line: + if line.strip(): + block.append(line) + else: + flush_block() result.append("") - continue - trimmed = line.rstrip() - result.append(" " * indent + trimmed) + flush_block() return result def _process_inline(self, text: str) -> str: diff --git a/output.txt b/output.txt new file mode 100644 index 0000000..549e49c --- /dev/null +++ b/output.txt @@ -0,0 +1,163 @@ + _ _ _ _ _ _ ___ __ +| |__ / | | | | | ___ __ _ __| (_)_ __ __ _ ( _ ) \ \ +| '_ \| | | |_| |/ _ \/ _` |/ _` | | '_ \ / _` | / _ \ _____| | +| | | | | | _ | __/ (_| | (_| | | | | | (_| | | (_) |_____| | +|_| |_|_| |_| |_|\___|\__,_|\__,_|_|_| |_|\__, | \___/ | | + |___/ /_/ + + _ ____ _ _ _ _ +| |__ |___ \ | | | | ___ __ _ __| (_)_ __ __ _ +| '_ \ __) | | |_| |/ _ \/ _` |/ _` | | '_ \ / _` | +| | | |/ __/ | _ | __/ (_| | (_| | | | | | (_| | +|_| |_|_____| |_| |_|\___|\__,_|\__,_|_|_| |_|\__, | + |___/ + + _ _____ _ _ _ _ +| |__ |___ / | | | | ___ __ _ __| (_)_ __ __ _ +| '_ \ |_ \ | |_| |/ _ \/ _` |/ _` | | '_ \ / _` | +| | | |___) | | _ | __/ (_| | (_| | | | | | (_| | +|_| |_|____/ |_| |_|\___|\__,_|\__,_|_|_| |_|\__, | + |___/ + +H4 HEADING +---------- + +H5 HEADING +---------- + +H6 HEADING +---------- + + + _ _ _ _ _ ____ _ +| | | | ___ _ __(_)_______ _ __ | |_ __ _| | | _ \ _ _| | ___ ___ +| |_| |/ _ \| '__| |_ / _ \| '_ \| __/ _` | | | |_) | | | | |/ _ \/ __| +| _ | (_) | | | |/ / (_) | | | | || (_| | | | _ <| |_| | | __/\__ \ +|_| |_|\___/|_| |_/___\___/|_| |_|\__\__,_|_| |_| \_\\__,_|_|\___||___/ + + + +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- + + _____ _ _ +| ____|_ __ ___ _ __ | |__ __ _ ___(_)___ +| _| | '_ ` _ \| '_ \| '_ \ / _` / __| / __| +| |___| | | | | | |_) | | | | (_| \__ \ \__ \ +|_____|_| |_| |_| .__/|_| |_|\__,_|___/_|___/ + |_| + + +T H I S I S B O L D T E X T _T_H_I_S___I_S___B_O_L_D___T_E_X_T_ T h i s +i s i t a l i c t e x t _T_h_i_s___i_s___i_t_a_l_i_c___t_e_x_t_ +-S-t-r-i-k-e-t-h-r-o-u-g-h- + + ____ _ _ _ +| __ )| | ___ ___| | ____ _ _ _ ___ | |_ ___ ___ +| _ \| |/ _ \ / __| |/ / _` | | | |/ _ \| __/ _ \/ __| +| |_) | | (_) | (__| < (_| | |_| | (_) | || __/\__ \ +|____/|_|\___/ \___|_|\_\__, |\__,_|\___/ \__\___||___/ + |_| + + + | Blockquotes can also be nested... + | | by using additional greater-than signs right next to each other... + | | | or with spaces between arrows. + + _ _ _ +| | (_)___| |_ ___ +| | | / __| __/ __| +| |___| \__ \ |_\__ \ +|_____|_|___/\__|___/ + + + + _ _ _ _ +| | | |_ __ ___ _ __ __| | ___ _ __ ___ __| | +| | | | '_ \ / _ \| '__/ _` |/ _ \ '__/ _ \/ _` | +| |_| | | | | (_) | | | (_| | __/ | | __/ (_| | + \___/|_| |_|\___/|_| \__,_|\___|_| \___|\__,_| + + + ++ Create a list by starting a line with `+`, `-`, or `*` +- Marker character change forces new list start: +* Ac tristique libero volutpat at ++ Facilisis in pretium nisl aliquet +- Nulla volutpat aliquam velit ++ Very easy + + ___ _ _ + / _ \ _ __ __| | ___ _ __ ___ __| | +| | | | '__/ _` |/ _ \ '__/ _ \/ _` | +| |_| | | | (_| | __/ | | __/ (_| | + \___/|_| \__,_|\___|_| \___|\__,_| + + + +1. Lorem ipsum dolor sit amet +2. Consectetur adipiscing elit +3. Integer molestie lorem at massa + + ____ _ + / ___|___ __| | ___ +| | / _ \ / _` |/ _ \ +| |__| (_) | (_| | __/ + \____\___/ \__,_|\___| + + + +Inline `code` + +Indented code + + 01 | // Some comments + 02 | line 1 of code + 03 | line 2 of code + 04 | line 3 of code + + + +Block code "fences" + + 01 | Sample text here... + + +Syntax highlighting + + 01 | var foo = function (bar) { + 02 | return bar++; + 03 | }; + 04 | + 05 | console.log(foo(5)); + + + _ _ _ +| | (_)_ __ | | _____ +| | | | '_ \| |/ / __| +| |___| | | | | <\__ \ +|_____|_|_| |_|_|\_\___/ + + + +[link text](1) + +[link with title](2) + + ___ +|_ _|_ __ ___ __ _ __ _ ___ ___ + | || '_ ` _ \ / _` |/ _` |/ _ \/ __| + | || | | | | | (_| | (_| | __/\__ \ +|___|_| |_| |_|\__,_|\__, |\___||___/ + |___/ + + +[Image: Minion](3) [Image: Stormtroopocat](4) + +[1] http://dev.nodeca.com +[2] http://nodeca.github.io/pica/demo/ +[3] https://octodex.github.com/images/minion.png +[4] https://octodex.github.com/images/stormtroopocat.jpg