HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //home/ubuntu/neovim/.deps/build/src/treesitter_vimdoc/test/corpus/codeblock.txt
================================================================================
simple codeblock
================================================================================
>
  1.1
<   

block2:
>
  2.1
<   foo

block3:
>
  3.1
<

  text


--------------------------------------------------------------------------------

(help_file
  (block
    (line
      (codeblock
        (code
          (line)))))
  (block
    (line
      (word))
    (line
      (codeblock
        (code
          (line)))))
  (block
    (line
      (word)))
  (block
    (line
      (word))
    (line
      (codeblock
        (code
          (line)))))
  (block
    (line
      (word))))

================================================================================
codeblock with text before
================================================================================
This code: >
  code-line1
  code-line2
  code-line3
<

From luaref.txt:

        (see |luaref-luaL_newstate|).
>
            static void *l_alloc (void *ud, void *ptr) {
              return NULL;
            }
<

text


--------------------------------------------------------------------------------

(help_file
  (block
    (line
      (word)
      (word)
      (codeblock
        (code
          (line)
          (line)
          (line)))))
  (block
    (line
      (word)
      (word)))
  (block
    (line
      (word)
      (word)
      (taglink
        (word))
      (word))
    (line
      (codeblock
        (code
          (line)
          (line)
          (line)))))
  (block
    (line
      (word))))

================================================================================
codeblock with language annotations
================================================================================
This code is in Lua: >lua
  local foo = 'bar'
<

This code is in Vimscript: >vim
  let foo = "bar"
<

--------------------------------------------------------------------------------

(help_file
  (block
    (line
      (word)
      (word)
      (word)
      (word)
      (word)
      (codeblock
        (language)
        (code
          (line)))))
  (block
    (line
      (word)
      (word)
      (word)
      (word)
      (word)
      (codeblock
        (language)
        (code
          (line))))))

================================================================================
codeblock with implicit stop
================================================================================
>
  line1
  line2

===============================
h1-headline *foo*
line1

line2

>
  line1

-------------------------------
h2-headline *foo*

>
  line1

H3 HEADLINE *foo*


--------------------------------------------------------------------------------

(help_file
  (block
    (line
      (codeblock
        (code
          (line)
          (line)
          (line))))
    (line
      (h1
        (word)
        (tag
          (word))))
    (line
      (word)))
  (block
    (line
      (word)))
  (block
    (line
      (codeblock
        (code
          (line)
          (line))))
    (line
      (h2
        (word)
        (tag
          (word)))))
  (block
    (line
      (codeblock
        (code
          (line)
          (line))))
    (line
      (h3
        (uppercase_name)
        (tag
          (word))))))

================================================================================
codeblock with empty lines
================================================================================

Example: >

    - let buf = nvim_create_buf(v:false, v:true)
    - call nvim_buf_set_lines(buf, 0, -1, v:true, ["test", "text"])

    let opts = {'relative': 'cursor', 'width': 10, 'height': 2, 'col': 0,
        \ 'row': 1, 'anchor': 'NW', 'style': 'minimal'}

    let win = nvim_open_win(buf, 0, opts)
    call nvim_win_set_option(win, 'winhl', 'Normal:MyHighlight')
x


--------------------------------------------------------------------------------

(help_file
  (block
    (line
      (word)
      (codeblock
        (code
          (line)
          (line)
          (line)
          (line)
          (line)
          (line)
          (line)
          (line)
          (line))))
    (line
      (word))))

================================================================================
tricky codeblock
================================================================================
>
  line1 >
  line2
  < line3
<

    Example: >

        vim.spell.check()
        -->
        {
            {'quik', 'bad', 4}
        }
<

tricky


--------------------------------------------------------------------------------

(help_file
  (block
    (line
      (codeblock
        (code
          (line)
          (line)
          (line)))))
  (block
    (line
      (word)
      (codeblock
        (code
          (line)
          (line)
          (line)
          (line)
          (line)
          (line)))))
  (block
    (line
      (word))))

================================================================================
strange codeblock
================================================================================
Note that in the command: >
	:if "foo"
	:" NOT executed
"foo" is converted to 0, which means FALSE.  If the string starts with a
non-zero number it means TRUE: >
	:if "8foo"
	:" executed
To test for a non-empty string, use empty(): >
	:if !empty("foo")
<

--------------------------------------------------------------------------------

(help_file
  (block
    (line
      (word)
      (word)
      (word)
      (word)
      (word)
      (codeblock
        (code
          (line)
          (line))))
    (line
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word))
    (line
      (word)
      (word)
      (word)
      (word)
      (word)
      (codeblock
        (code
          (line)
          (line))))
    (line
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (codeblock
        (code
          (line))))))

================================================================================
codeblock stop and start on same line
================================================================================
    Examples: >
        :lua vim.api.nvim_command('echo "Hello, Nvim!"')
<    LuaJIT: >
        :lua =jit.version
<
    *:lua-heredoc*
:lua << [endmarker]
{script}

    Example: >
        lua << EOF
        EOF
<

--------------------------------------------------------------------------------

(help_file
  (block
    (line
      (word)
      (codeblock
        (code
          (line)))))
  (block
    (line
      (word)
      (codeblock
        (code
          (line)))))
  (block
    (line
      (tag
        (word)))
    (line
      (word)
      (word)
      (word)
      (word))
    (line
      (argument
        (word))))
  (block
    (line
      (word)
      (codeblock
        (code
          (line)
          (line))))))

================================================================================
NOT codeblock: whitespace after ">"
================================================================================
x > 
  line

x x> 
  line

Not a language annotation: > lua
  line

Not a language annotation: >lua is not at EOL
  line


--------------------------------------------------------------------------------

(help_file
  (block
    (line
      (word)
      (word))
    (line
      (word)))
  (block
    (line
      (word)
      (word))
    (line
      (word)))
  (block
    (line
      (word)
      (word)
      (word)
      (word)
      (word)
      (word))
    (line
      (word)))
  (block
    (line
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word)
      (word))
    (line
      (word))))