vim-instant-markdown icon indicating copy to clipboard operation
vim-instant-markdown copied to clipboard

Place autoscroll marker on new line after previous empty line that is…

Open philip4096 opened this issue 3 years ago • 3 comments

… followed by a non-empty line to prevent marker from interfering with multiline latex equations. Issue #203

philip4096 avatar Mar 28 '22 09:03 philip4096

Thank you for the feedback. Using search seems like a good idea.

But I don’t see how the other option could be used to ignore a tag that is inside a latex equation, but perhaps I have misunderstood something.

27 maj 2022 kl. 15:23 skrev Ashwin V. Mohanan @.***>:

 @ashwinvis commented on this pull request.

In ftplugin/markdown/instant-markdown.vim:

  • "From lines[row_num] find the previous empty line that is followed by a non-empty line, or the first line.
  • while ( row_num > 0 ) && !(lines[row_num] =~ '^\s*$' && !(lines[row_num + 1] =~ '^\s*$'))
  •  let row_num += -1
    
  • endwhile TBH, I think this while loop might be overkill. If this is the solution I wonder if we can replace this with a Vim search.

In ftplugin/markdown/instant-markdown.vim:

@@ -158,7 +158,17 @@ function! s:bufGetLines(bufnr) if g:instant_markdown_autoscroll " inject row marker let row_num = max([0, line(".") - 5])

  • let lines[row_num] = join([lines[row_num], ''], ' ')
  • if len(lines) < 3
  •  return lines
    
  • endif
  • "From lines[row_num] find the previous empty line that is followed by a non-empty line, or the first line.
  • while ( row_num > 0 ) && !(lines[row_num] =~ '^\s*$' && !(lines[row_num + 1] =~ '^\s*$'))
  •  let row_num += -1
    
  • endwhile
  • "Insert new line with marker otherwise two paragraphs might be fused.
  • call insert(lines, '', row_num) I wonder if we can solve this by adding class="mathjax_ignore" as documented here:

https://docs.mathjax.org/en/latest/options/document.html

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

philip4096 avatar May 28 '22 09:05 philip4096

I added a commit with while-loop replaced by search. Perhaps the regex pattern can be improved but it seems to work well. I also removed code to subtract 5 from current line number before starting search because I could not think of an easy way to use search together with that requirement. Also it seems like it isn't needed. What do you think?

philip4096 avatar May 31 '22 10:05 philip4096

It looks good. I will test it out.

ashwinvis avatar Jun 03 '22 16:06 ashwinvis

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 03 '22 04:12 stale[bot]