Subject: mailing-list for TeXmacs Users
List archive
From : Sam Liddicott <address@hidden>- To: TeXmacs user list <address@hidden>
- Subject: I hope there's a prize - auto itemized paragraphs with line wrapping
- Date: Wed, 14 Feb 2024 02:29:53 +0000
About 13 years after I first tried to get this working (https://lists.gnu.org/archive/html/texmacs-dev/2011-04/msg00011.html), I have finally got auto-itemized paragraphs working with line wrap, shown here in a table cell!
The only other way to implement wrapping is to collect the paragraph element into a concat element, as then they seem to not depend (for line wrapping) on whatever internal hack required the document tag to remain attached; but that runs all the separate paragraphs back into one paragraph.
The final part of the puzzle was to use the <newline> tag, which as the documentation says: is a deprecated tag in order to split a logical paragraph into several logical paragraphs without creating explicit subtrees for all paragraphs.
(Or do it in scheme, but where's the fun in that?)
The reason all auto-listers have failed up till now is that in order for paragraph subtrees to properly wrap, they need to remain attached to the parent document element that was passed as the parameter, but the only way to modify the paragraphs is to use map-args and to modify them and attach them to a new document element.
The only other way to implement wrapping is to collect the paragraph element into a concat element, as then they seem to not depend (for line wrapping) on whatever internal hack required the document tag to remain attached; but that runs all the separate paragraphs back into one paragraph.
The final part of the puzzle was to use the <newline> tag, which as the documentation says: is a deprecated tag in order to split a logical paragraph into several logical paragraphs without creating explicit subtrees for all paragraphs.
We can hope that like <nextline> tag, it will last until "the paragraph primitive" will be correctly implemented.
(Or do it in scheme, but where's the fun in that?)
And may the <newline> tag last forever.
Do I get a prize?
Sam
<TeXmacs|2.1.2> <style|source> <\body> <\active*> <\src-title> <src-style-file|auto-lists|1.0> <\src-purpose> Automatic list itemization, no need for \<less\>item\<gtr\> tags to pollute your semantic markup </src-purpose> <\src-copyright|2024> Sam Liddicott </src-copyright> <\src-license> This software falls under the <hlink|GNU general public license, version 3 or later|$TEXMACS_PATH/LICENSE>. It comes WITHOUT ANY WARRANTY WHATSOEVER. You should have received a copy of the license which the software. If not, see <hlink|http://www.gnu.org/licenses/gpl-3.0.html|http://www.gnu.org/licenses/gpl-3.0.html>. </src-license> </src-title> </active*> <use-package|generic> <\active*> <\src-comment> These are public macros but you almost always want to use \<less\>auto-list-with\|...\<gtr\> Just pass any document tree and each paragraph will be decorated with auto-list-decorate </src-comment> </active*> <assign|auto-list|<macro|x|<auto-list-reform-tree|<arg|x>>>> <assign|auto-list-with|<macro|foo|x|<with|auto-list-decorate|<arg|foo>|<auto-list|<arg|x>>>>> <assign|auto-list-decorate|<macro|x|<surround|<item>|<new-line>|<arg|x>>>> <\active*> <\src-comment> The purpose of text-present is to guess whether or not there is any list-item text to show. This allows the user to hide the list and show the text entry point at some suitable point instead. It works best when it operating on un-processed input. </src-comment> </active*> <assign|text-present|<macro|x|<if|<equal|<get-label|<arg|x>>|string>|<greater|<length|<arg|x>>|0>|<if|<equal|<get-label|<arg|x>>|document>|<if|<equal|0|<quasi|<length|<tuple|<unquote*|<arg|x>>>>>>|false|<if|<equal|1|<quasi|<length|<tuple|<unquote*|<arg|x>>>>>>|<quasi|<text-present|<unquote*|<arg|x>>>>|true>>|false>>>> <\active*> <\src-comment> The reason all auto-listers have failed up till now is that in order for paragraph subtrees to properly wrap, they need to remain attached to the parent document element that was passed as the parameter, but the only way to modify the paragraphs is to use map-args and to modify them and attach them to a new document element. The only other way to implement wrapping is to collect the paragraph element into a concat element, as then they seem to not depend (for line wrapping) on whatever internal hack required the document tag to remain attached; but that runs all the separate paragraphs back into one paragraph. The final part of the puzzle was to use the <inactive*|<newline>> tag, which as the documentation says: is a deprecated tag in order to split a logical paragraph into several logical paragraphs without creating explicit subtrees for all paragraphs. We can hope that like <inactive*|<nextline>> tag, it will last until the<nbsp><with|color|blue|paragraph><nbsp>primitive will be correctly implemented. (Or do it in scheme, but where's the fun in that?) </src-comment> </active*> <assign|auto-list-reform-document*|<xmacro|x|<quasi|<map-args|auto-list-reform-text|concat|x>>>> <assign|auto-list-reform-document|<macro|x|<quasi|<auto-list-reform-document*|<unquote*|<arg|x>>>>>> <assign|auto-list-reform-tree-recurse|<macro|x|<quasi|<uce|<unquote*|<arg|x>>>>>> <assign|auto-list-reform-text|<macro|x|<auto-list-decorate|<arg|x>>>> <\active*> <\src-comment> The purpose of this function is to strip useless document elements that got inadvertently added (I wonder if I need to do that any more), and otherwise enumerate document tags for non-document content, and treat all non-document content with the decorator </src-comment> </active*> <assign|auto-list-reform-tree|<macro|x|<compound|<if|<equal|<get-label|<arg|x>>|string>|auto-list-reform-text|<if|<equal|<get-label|<arg|x>>|document>|<if|<equal|0|<quasi|<length|<tuple|<unquote*|<arg|x>>>>>>|uninit|<if|<equal|1|<quasi|<length|<tuple|<unquote*|<arg|x>>>>>>|auto-list-reform-tree-recurse|auto-list-reform-document>>|auto-list-reform-text>>|<arg|x>>>> <\active*> <\src-comment> And here is the proof. </src-comment> </active*> <assign|auto-list-test-list|<\macro|x> <\itemize-dot> <auto-list|<arg|x>> </itemize-dot> </macro>> <block|<tformat|<twith|table-hmode|exact>|<cwith|1|1|1|1|cell-hyphen|t>|<twith|table-width|0.5par>|<table|<row|<\cell> <\auto-list-test-list> <with|color|blue|\<less\>><with|color|blue|new-line><label|auto-25><with|color|blue|\<gtr\>> <with|color|dark grey|(start a new paragraph)> This is a deprecated tag in order to split a logical paragraph into several logical paragraphs without creating explicit subtrees for all paragraphs. We recall that logical paragraphs are important structures for the typesetting process. Many primitives and environment variables (vertical spacing, paragraph style, indentation, page breaking, etc.) operate on whole paragraphs or at the boundaries of the enclosing paragraph. </auto-list-test-list> </cell>>>>> <\auto-list-test-list> <with|color|blue|\<less\>><with|color|blue|new-line><label|auto-25><with|color|blue|\<gtr\>> <with|color|dark grey|(start a new paragraph)> This is a deprecated tag in order to split a logical paragraph into several logical paragraphs without creating explicit subtrees for all paragraphs. We recall that logical paragraphs are important structures for the typesetting process. Many primitives and environment variables (vertical spacing, paragraph style, indentation, page breaking, etc.) operate on whole paragraphs or at the boundaries of the enclosing paragraph. </auto-list-test-list> \; </body> <\initial> <\collection> <associate|preamble|true> </collection> </initial>
- I hope there's a prize - auto itemized paragraphs with line wrapping, Sam Liddicott, 02/14/2024
- Re: I hope there's a prize - auto itemized paragraphs with line wrapping, Sam Liddicott, 02/14/2024
- Re: I hope there's a prize - auto itemized paragraphs with line wrapping, Giovanni Piredda, 02/14/2024
Archive powered by MHonArc 2.6.24.