Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paragraphs (and nested paragraphs?) #13

Closed
justinmk opened this issue Sep 6, 2022 · 0 comments · Fixed by #16
Closed

paragraphs (and nested paragraphs?) #13

justinmk opened this issue Sep 6, 2022 · 0 comments · Fixed by #16

Comments

@justinmk
Copy link
Member

justinmk commented Sep 6, 2022

Preamble from #12 :

In order for :help to render as something other than fixed-width, hard-wrapped text, (e.g. for HTML format) the parser needs to give some basic hints about structure besides "line". Sometimes (often) the :help source needs to be fixed (because it can't be reasonably parsed), but in other common cases it's probably reasonable for tree-sitter-vimdoc to provide some basic idea of:

  1. paragraph (and "nested" paragraphs? AKA indentation) [this issue]
  2. list items (which may be nested) list items (and nested list items) #12

Example of paragraphs and nested (indented) paragraphs

https://github.com/neovim/neovim/blob/52e4b779e3df1335efc4774e8dfc199d07e24bfd/runtime/doc/eval.txt#L51-L74

By "nested paragraphs" I simply mean blocks of text that have common indentation. In the following example,

  • we can't parse the Number 123... block but if we can at least recognize that it is indented, then the HTML result can wrap that block in <pre> so that it is readable.
  • the *octal* line doesn't share indentation so it should be parsed as a normal "line", possibly part of the next paragraph.
  • it may be reasonable for us to require blank lines between these blocks.
The Number and String types are converted automatically, depending on how they
are used.

Conversion from a Number to a String is by making the ASCII representation of
the Number.  Examples:
	Number 123	-->	String "123" ~
	Number 0	-->	String "0" ~
	Number -1	-->	String "-1" ~
							*octal*
Conversion from a String to a Number is done by converting the first digits to
a number.  Hexadecimal "0xf9", Octal "017" or "0o17", and Binary "0b10"
numbers are recognized.  If the String doesn't start with digits, the result
is zero. Examples:
	String "456"	-->	Number 456 ~
	String "6bar"	-->	Number 6 ~
	String "foo"	-->	Number 0 ~
	String "0xf1"	-->	Number 241 ~
	String "0100"	-->	Number 64 ~
	String "0o100"	-->	Number 64 ~
	String "0b101"	-->	Number 5 ~
	String "-8"	-->	Number -8 ~
	String "+8"	-->	Number 0 ~

To force conversion from String to Number, add zero to it: >
	:echo "0100" + 0
<	64 ~

To avoid a leading zero to cause octal conversion, or for using a different
base, use |str2nr()|.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant