Adds email style quotes to signal blockquotes
This commit is contained in:
		
				
					committed by
					
						 Tinmarino
						Tinmarino
					
				
			
			
				
	
			
			
			
						parent
						
							e3e841f335
						
					
				
				
					commit
					12327c6f90
				
			| @@ -664,6 +664,13 @@ function! s:close_tag_quote(quote, ldest) abort | |||||||
|   return a:quote |   return a:quote | ||||||
| endfunction | endfunction | ||||||
|  |  | ||||||
|  | function! s:close_tag_arrow_quote(arrow_quote, ldest) abort | ||||||
|  |   if a:arrow_quote | ||||||
|  |     call insert(a:ldest, '</p></blockquote>') | ||||||
|  |     return 0 | ||||||
|  |   endif | ||||||
|  |   return a:arrow_quote | ||||||
|  | endfunction | ||||||
|  |  | ||||||
| function! s:close_tag_para(para, ldest) abort | function! s:close_tag_para(para, ldest) abort | ||||||
|   if a:para |   if a:para | ||||||
| @@ -915,9 +922,33 @@ function! s:process_tag_quote(line, quote) abort | |||||||
|   return [processed, lines, quote] |   return [processed, lines, quote] | ||||||
| endfunction | endfunction | ||||||
|  |  | ||||||
|  | function! s:process_tag_arrow_quote(line, arrow_quote) abort | ||||||
|  |   let lines = [] | ||||||
|  |   let arrow_quote = a:arrow_quote | ||||||
|  |   let processed = 0 | ||||||
|  |   if a:line =~# '^>' | ||||||
|  |     if !arrow_quote | ||||||
|  |       call add(lines, '<blockquote>') | ||||||
|  |       call add(lines, '<p>') | ||||||
|  |       let arrow_quote = 1 | ||||||
|  |     endif | ||||||
|  |     let processed = 1 | ||||||
|  |     let stripped_line = substitute(a:line, '^>\s*', '', '') | ||||||
|  |     if stripped_line =~# '^\s*$' | ||||||
|  |       call add(lines, '</p>') | ||||||
|  |       call add(lines, '<p>') | ||||||
|  |     endif | ||||||
|  |     call add(lines, stripped_line) | ||||||
|  |   elseif arrow_quote | ||||||
|  |     call add(lines, '</p>') | ||||||
|  |     call add(lines, '</blockquote>') | ||||||
|  |     let arrow_quote = 0 | ||||||
|  |   endif | ||||||
|  |   return [processed, lines, arrow_quote] | ||||||
|  | endfunction | ||||||
|  |  | ||||||
|  |  | ||||||
| function! s:process_tag_list(line, lists) abort | function! s:process_tag_list(line, lists) abort | ||||||
|  |  | ||||||
|   function! s:add_checkbox(line, rx_list) abort |   function! s:add_checkbox(line, rx_list) abort | ||||||
|     let st_tag = '<li>' |     let st_tag = '<li>' | ||||||
|     let chk = matchlist(a:line, a:rx_list) |     let chk = matchlist(a:line, a:rx_list) | ||||||
| @@ -1209,6 +1240,7 @@ function! s:parse_line(line, state) abort | |||||||
|   let state = {} |   let state = {} | ||||||
|   let state.para = a:state.para |   let state.para = a:state.para | ||||||
|   let state.quote = a:state.quote |   let state.quote = a:state.quote | ||||||
|  |   let state.arrow_quote = a:state.arrow_quote | ||||||
|   let state.pre = a:state.pre[:] |   let state.pre = a:state.pre[:] | ||||||
|   let state.math = a:state.math[:] |   let state.math = a:state.math[:] | ||||||
|   let state.table = a:state.table[:] |   let state.table = a:state.table[:] | ||||||
| @@ -1245,6 +1277,9 @@ function! s:parse_line(line, state) abort | |||||||
|       if processed && state.quote |       if processed && state.quote | ||||||
|         let state.quote = s:close_tag_quote(state.quote, lines) |         let state.quote = s:close_tag_quote(state.quote, lines) | ||||||
|       endif |       endif | ||||||
|  |       if processed && state.arrow_quote | ||||||
|  |         let state.arrow_quote = s:close_tag_arrow_quote(state.arrow_quote, lines) | ||||||
|  |       endif | ||||||
|       if processed && state.para |       if processed && state.para | ||||||
|         let state.para = s:close_tag_para(state.para, lines) |         let state.para = s:close_tag_para(state.para, lines) | ||||||
|       endif |       endif | ||||||
| @@ -1278,6 +1313,9 @@ function! s:parse_line(line, state) abort | |||||||
|     if processed && state.quote |     if processed && state.quote | ||||||
|       let state.quote = s:close_tag_quote(state.quote, lines) |       let state.quote = s:close_tag_quote(state.quote, lines) | ||||||
|     endif |     endif | ||||||
|  |     if processed && state.arrow_quote | ||||||
|  |       let state.arrow_quote = s:close_tag_arrow_quote(state.arrow_quote, lines) | ||||||
|  |     endif | ||||||
|     if processed && state.para |     if processed && state.para | ||||||
|       let state.para = s:close_tag_para(state.para, lines) |       let state.para = s:close_tag_para(state.para, lines) | ||||||
|     endif |     endif | ||||||
| @@ -1340,6 +1378,9 @@ function! s:parse_line(line, state) abort | |||||||
|     if processed && state.quote |     if processed && state.quote | ||||||
|       let state.quote = s:close_tag_quote(state.quote, lines) |       let state.quote = s:close_tag_quote(state.quote, lines) | ||||||
|     endif |     endif | ||||||
|  |     if processed && state.arrow_quote | ||||||
|  |       let state.arrow_quote = s:close_tag_arrow_quote(state.arrow_quote, lines) | ||||||
|  |     endif | ||||||
|     if processed && state.pre[0] |     if processed && state.pre[0] | ||||||
|       let state.pre = s:close_tag_pre(state.pre, lines) |       let state.pre = s:close_tag_pre(state.pre, lines) | ||||||
|     endif |     endif | ||||||
| @@ -1370,7 +1411,8 @@ function! s:parse_line(line, state) abort | |||||||
|       let state.table = s:close_tag_table(state.table, res_lines, state.header_ids) |       let state.table = s:close_tag_table(state.table, res_lines, state.header_ids) | ||||||
|       let state.pre = s:close_tag_pre(state.pre, res_lines) |       let state.pre = s:close_tag_pre(state.pre, res_lines) | ||||||
|       let state.math = s:close_tag_math(state.math, res_lines) |       let state.math = s:close_tag_math(state.math, res_lines) | ||||||
|       let state.quote = s:close_tag_quote(state.quote, res_lines) |       let state.quote = s:close_tag_quote(state.quote || state.arrow_quote, res_lines) | ||||||
|  |       let state.arrow_quote = s:close_tag_arrow_quote(state.arrow_quote, lines) | ||||||
|       let state.para = s:close_tag_para(state.para, res_lines) |       let state.para = s:close_tag_para(state.para, res_lines) | ||||||
|  |  | ||||||
|       call add(res_lines, line) |       call add(res_lines, line) | ||||||
| @@ -1387,6 +1429,39 @@ function! s:parse_line(line, state) abort | |||||||
|     if processed && state.deflist |     if processed && state.deflist | ||||||
|       let state.deflist = s:close_tag_def_list(state.deflist, lines) |       let state.deflist = s:close_tag_def_list(state.deflist, lines) | ||||||
|     endif |     endif | ||||||
|  |     if processed && state.arrow_quote | ||||||
|  |       let state.quote = s:close_tag_arrow_quote(state.arrow_quote, lines) | ||||||
|  |     endif | ||||||
|  |     if processed && len(state.table) | ||||||
|  |       let state.table = s:close_tag_table(state.table, lines, state.header_ids) | ||||||
|  |     endif | ||||||
|  |     if processed && state.pre[0] | ||||||
|  |       let state.pre = s:close_tag_pre(state.pre, lines) | ||||||
|  |     endif | ||||||
|  |     if processed && state.math[0] | ||||||
|  |       let state.math = s:close_tag_math(state.math, lines) | ||||||
|  |     endif | ||||||
|  |     if processed && state.para | ||||||
|  |       let state.para = s:close_tag_para(state.para, lines) | ||||||
|  |     endif | ||||||
|  |  | ||||||
|  |     call map(lines, 's:process_inline_tags(v:val, state.header_ids)') | ||||||
|  |  | ||||||
|  |     call extend(res_lines, lines) | ||||||
|  |   endif | ||||||
|  |  | ||||||
|  |   " arrow quotes | ||||||
|  |   if !processed | ||||||
|  |     let [processed, lines, state.arrow_quote] = s:process_tag_arrow_quote(line, state.arrow_quote) | ||||||
|  |     if processed && state.quote | ||||||
|  |       let state.quote = s:close_tag_quote(state.quote, lines) | ||||||
|  |     endif | ||||||
|  |     if processed && len(state.lists) | ||||||
|  |       call s:close_tag_list(state.lists, lines) | ||||||
|  |     endif | ||||||
|  |     if processed && state.deflist | ||||||
|  |       let state.deflist = s:close_tag_def_list(state.deflist, lines) | ||||||
|  |     endif | ||||||
|     if processed && len(state.table) |     if processed && len(state.table) | ||||||
|       let state.table = s:close_tag_table(state.table, lines, state.header_ids) |       let state.table = s:close_tag_table(state.table, lines, state.header_ids) | ||||||
|     endif |     endif | ||||||
| @@ -1435,8 +1510,11 @@ function! s:parse_line(line, state) abort | |||||||
|     if processed && len(state.lists) |     if processed && len(state.lists) | ||||||
|       call s:close_tag_list(state.lists, lines) |       call s:close_tag_list(state.lists, lines) | ||||||
|     endif |     endif | ||||||
|     if processed && state.quote |     if processed && (state.quote || state.arrow_quote) | ||||||
|       let state.quote = s:close_tag_quote(state.quote, res_lines) |       let state.quote = s:close_tag_quote(state.quote || state.arrow_quote, lines) | ||||||
|  |     endif | ||||||
|  |     if processed && state.arrow_quote | ||||||
|  |       let state.arrow_quote = s:close_tag_arrow_quote(state.arrow_quote, lines) | ||||||
|     endif |     endif | ||||||
|     if processed && state.pre[0] |     if processed && state.pre[0] | ||||||
|       let state.pre = s:close_tag_pre(state.pre, res_lines) |       let state.pre = s:close_tag_pre(state.pre, res_lines) | ||||||
| @@ -1535,6 +1613,7 @@ function! s:convert_file(path_html, wikifile) abort | |||||||
|     let state = {} |     let state = {} | ||||||
|     let state.para = 0 |     let state.para = 0 | ||||||
|     let state.quote = 0 |     let state.quote = 0 | ||||||
|  |     let state.arrow_quote = 0 | ||||||
|     let state.pre = [0, 0] " [in_pre, indent_pre] |     let state.pre = [0, 0] " [in_pre, indent_pre] | ||||||
|     let state.math = [0, 0] " [in_math, indent_math] |     let state.math = [0, 0] " [in_math, indent_math] | ||||||
|     let state.table = [] |     let state.table = [] | ||||||
| @@ -1595,6 +1674,7 @@ function! s:convert_file(path_html, wikifile) abort | |||||||
|     " close opened tags if any |     " close opened tags if any | ||||||
|     let lines = [] |     let lines = [] | ||||||
|     call s:close_tag_quote(state.quote, lines) |     call s:close_tag_quote(state.quote, lines) | ||||||
|  |     call s:close_tag_arrow_quote(state.arrow_quote, lines) | ||||||
|     call s:close_tag_para(state.para, lines) |     call s:close_tag_para(state.para, lines) | ||||||
|     call s:close_tag_pre(state.pre, lines) |     call s:close_tag_pre(state.pre, lines) | ||||||
|     call s:close_tag_math(state.math, lines) |     call s:close_tag_math(state.math, lines) | ||||||
|   | |||||||
| @@ -1449,6 +1449,14 @@ Text which starts with 4 or more spaces is a blockquote. | |||||||
|     could be styled by CSS in HTML. Blockquotes are usually used to quote a |     could be styled by CSS in HTML. Blockquotes are usually used to quote a | ||||||
|     long piece of text from another source. |     long piece of text from another source. | ||||||
|  |  | ||||||
|  | A group of lines prefixed with > also specifies a blockquote, with the caveat | ||||||
|  | that the > syntax allow empty lines to signal multiple parragraphs. | ||||||
|  |  | ||||||
|  | > This also signals a block quote. | ||||||
|  | >  | ||||||
|  | > You can use empty lines to signal multiple paragraphs kept inside the same | ||||||
|  | > blockquote. | ||||||
|  |  | ||||||
|  |  | ||||||
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ||||||
| 5.10. Comments                                       *vimwiki-syntax-comments* | 5.10. Comments                                       *vimwiki-syntax-comments* | ||||||
| @@ -3633,6 +3641,7 @@ Contributors and their Github usernames in roughly chronological order: | |||||||
|     - flex (@bratekarate) |     - flex (@bratekarate) | ||||||
|     - Marius Lopez (@PtitCaius) |     - Marius Lopez (@PtitCaius) | ||||||
|     - Edward Bassett (@ebassett) |     - Edward Bassett (@ebassett) | ||||||
|  |     - Rafael Castillo (@eltrufas) | ||||||
|  |  | ||||||
| ============================================================================== | ============================================================================== | ||||||
| 16. Changelog                                              *vimwiki-changelog* | 16. Changelog                                              *vimwiki-changelog* | ||||||
| @@ -3648,6 +3657,7 @@ New:~ | |||||||
|     * PR #919: Fix duplicate helptag |     * PR #919: Fix duplicate helptag | ||||||
|     * PR #907: Cycle bullets |     * PR #907: Cycle bullets | ||||||
|     * PR #900: conceallevel is now setted locally for vimwiki buffers |     * PR #900: conceallevel is now setted locally for vimwiki buffers | ||||||
|  |     * PR #901: adds multiparagraph blockquotes using email style syntax | ||||||
|  |  | ||||||
| 2.5 (2020-05-26)~ | 2.5 (2020-05-26)~ | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user