Markdown Vim Mode
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.7 KiB

  1. Given markdown;
  2. a <http://b> c
  3. Execute (gx autolink):
  4. let b:url = 'http://b'
  5. let b:line = getline(1)
  6. let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
  7. AssertEqual b:func(1, match(b:line, 'a') + 1), ''
  8. AssertEqual b:func(1, match(b:line, '<') + 1), b:url
  9. AssertEqual b:func(1, match(b:line, 'h') + 1), b:url
  10. AssertEqual b:func(1, match(b:line, '>') + 1), b:url
  11. AssertEqual b:func(1, match(b:line, 'c') + 1), ''
  12. Given markdown;
  13. a http://b.bb c
  14. Execute (gx implicit autolink):
  15. let b:url = 'http://b.bb'
  16. let b:line = getline(1)
  17. let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
  18. AssertEqual b:func(1, match(b:line, 'a') + 1), ''
  19. AssertEqual b:func(1, match(b:line, 'h') + 1), b:url
  20. AssertEqual b:func(1, match(b:line, 'c') + 1), ''
  21. Given markdown;
  22. [a]: http://b "c"
  23. Execute (gx link reference definition):
  24. let b:url = 'http://b'
  25. let b:line = getline(1)
  26. let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
  27. " TODO would be cool if all of the following gave the link.
  28. AssertEqual b:func(1, match(b:line, 'a') + 1), ''
  29. AssertEqual b:func(1, match(b:line, 'h') + 1), b:url
  30. AssertEqual b:func(1, match(b:line, 'c') + 1), ''
  31. Given markdown;
  32. a [b](c) d
  33. Execute (gx autolink):
  34. let b:url = 'c'
  35. let b:line = getline(1)
  36. let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
  37. AssertEqual b:func(1, match(b:line, 'a') + 1), ''
  38. AssertEqual b:func(1, match(b:line, '[') + 1), b:url
  39. AssertEqual b:func(1, match(b:line, 'b') + 1), b:url
  40. AssertEqual b:func(1, match(b:line, ']') + 1), b:url
  41. AssertEqual b:func(1, match(b:line, '(') + 1), b:url
  42. AssertEqual b:func(1, match(b:line, 'c') + 1), b:url
  43. AssertEqual b:func(1, match(b:line, ')') + 1), b:url
  44. AssertEqual b:func(1, match(b:line, 'd') + 1), ''
  45. Given markdown;
  46. # a
  47. b
  48. # c
  49. d
  50. Execute (]] same level):
  51. AssertEqual line('.'), 1
  52. normal ]]
  53. AssertEqual line('.'), 5
  54. normal [[
  55. AssertEqual line('.'), 1
  56. Given markdown;
  57. # a
  58. b
  59. ## c
  60. d
  61. Execute (]] different levels level):
  62. AssertEqual line('.'), 1
  63. normal ]]
  64. AssertEqual line('.'), 5
  65. normal [[
  66. AssertEqual line('.'), 1
  67. Given markdown;
  68. # a
  69. b
  70. ## c
  71. d
  72. # e
  73. f
  74. Execute (][ different levels level):
  75. AssertEqual line('.'), 1
  76. normal ][
  77. AssertEqual line('.'), 9
  78. normal []
  79. AssertEqual line('.'), 1
  80. Given markdown;
  81. # a
  82. b
  83. Execute (]c):
  84. normal! 3G
  85. AssertEqual line('.'), 3
  86. normal ]c
  87. AssertEqual line('.'), 1
  88. Given markdown;
  89. # a
  90. Execute (Toc does not set nomodifiable on other files):
  91. " Sanity check.
  92. Assert &modifiable
  93. :Toc
  94. :lclose
  95. :edit a
  96. Assert &modifiable