Mercurial > vim
comparison runtime/autoload/tohtml.vim @ 15033:f8b0f1e42f2c
Update runtime files.
commit https://github.com/vim/vim/commit/f0d58efc9dc46be37c629cbc99b4125448ca39fd
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Nov 16 16:13:44 2018 +0100
Update runtime files.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 16 Nov 2018 16:15:07 +0100 |
parents | 30042ddff503 |
children | cb3163d590a1 |
comparison
equal
deleted
inserted
replaced
15032:4b3b0ea9b09d | 15033:f8b0f1e42f2c |
---|---|
1 " Vim autoload file for the tohtml plugin. | 1 " Vim autoload file for the tohtml plugin. |
2 " Maintainer: Ben Fritz <fritzophrenic@gmail.com> | 2 " Maintainer: Ben Fritz <fritzophrenic@gmail.com> |
3 " Last Change: 2013 Sep 03 | 3 " Last Change: 2018 Nov 11 |
4 " | 4 " |
5 " Additional contributors: | 5 " Additional contributors: |
6 " | 6 " |
7 " Original by Bram Moolenaar <Bram@vim.org> | 7 " Original by Bram Moolenaar <Bram@vim.org> |
8 " Diff2HTML() added by Christian Brabandt <cb@256bit.org> | 8 " Diff2HTML() added by Christian Brabandt <cb@256bit.org> |
542 let style_start = search('^</head>')-1 | 542 let style_start = search('^</head>')-1 |
543 | 543 |
544 " add required javascript in reverse order so we can just call append again | 544 " add required javascript in reverse order so we can just call append again |
545 " and again without adjusting {{{ | 545 " and again without adjusting {{{ |
546 | 546 |
547 " insert script closing tag | 547 let s:uses_script = s:settings.dynamic_folds || s:settings.line_ids || !empty(s:settings.prevent_copy) |
548 call append(style_start, [ | 548 |
549 \ '', | 549 " insert script closing tag if needed |
550 \ s:settings.use_xhtml ? '//]]>' : '-->', | 550 if s:uses_script |
551 \ "</script>" | 551 call append(style_start, [ |
552 \ ]) | 552 \ '', |
553 \ s:settings.use_xhtml ? '//]]>' : '-->', | |
554 \ "</script>" | |
555 \ ]) | |
556 endif | |
553 | 557 |
554 " insert script which corrects the size of small input elements in | 558 " insert script which corrects the size of small input elements in |
555 " prevent_copy mode. See 2html.vim for details on why this is needed and how | 559 " prevent_copy mode. See 2html.vim for details on why this is needed and how |
556 " it works. | 560 " it works. |
557 if !empty(s:settings.prevent_copy) | 561 if !empty(s:settings.prevent_copy) |
573 \ ' document.getElementById("vimCodeElement'.s:settings.id_suffix.'").className = "em"+ratio;', | 577 \ ' document.getElementById("vimCodeElement'.s:settings.id_suffix.'").className = "em"+ratio;', |
574 \ ' }', | 578 \ ' }', |
575 \ '}' | 579 \ '}' |
576 \ ]) | 580 \ ]) |
577 endif | 581 endif |
578 " | 582 |
579 " insert javascript to get IDs from line numbers, and to open a fold before | 583 " insert javascript to get IDs from line numbers, and to open a fold before |
580 " jumping to any lines contained therein | 584 " jumping to any lines contained therein |
581 call append(style_start, [ | 585 if s:settings.line_ids |
582 \ " /* Always jump to new location even if the line was hidden inside a fold, or", | 586 call append(style_start, [ |
583 \ " * we corrected the raw number to a line ID.", | 587 \ " /* Always jump to new location even if the line was hidden inside a fold, or", |
584 \ " */", | 588 \ " * we corrected the raw number to a line ID.", |
585 \ " if (lineElem) {", | 589 \ " */", |
586 \ " lineElem.scrollIntoView(true);", | 590 \ " if (lineElem) {", |
587 \ " }", | 591 \ " lineElem.scrollIntoView(true);", |
588 \ " return true;", | 592 \ " }", |
589 \ "}", | 593 \ " return true;", |
590 \ "if ('onhashchange' in window) {", | 594 \ "}", |
591 \ " window.onhashchange = JumpToLine;", | 595 \ "if ('onhashchange' in window) {", |
592 \ "}" | 596 \ " window.onhashchange = JumpToLine;", |
593 \ ]) | 597 \ "}" |
594 if s:settings.dynamic_folds | 598 \ ]) |
599 | |
600 if s:settings.dynamic_folds | |
601 call append(style_start, [ | |
602 \ "", | |
603 \ " /* navigate upwards in the DOM tree to open all folds containing the line */", | |
604 \ " var node = lineElem;", | |
605 \ " while (node && node.id != 'vimCodeElement".s:settings.id_suffix."')", | |
606 \ " {", | |
607 \ " if (node.className == 'closed-fold')", | |
608 \ " {", | |
609 \ " /* toggle open the fold ID (remove window ID) */", | |
610 \ " toggleFold(node.id.substr(4));", | |
611 \ " }", | |
612 \ " node = node.parentNode;", | |
613 \ " }", | |
614 \ ]) | |
615 endif | |
616 endif | |
617 | |
618 if s:settings.line_ids | |
595 call append(style_start, [ | 619 call append(style_start, [ |
596 \ "", | 620 \ "", |
597 \ " /* navigate upwards in the DOM tree to open all folds containing the line */", | 621 \ "/* function to open any folds containing a jumped-to line before jumping to it */", |
598 \ " var node = lineElem;", | 622 \ "function JumpToLine()", |
599 \ " while (node && node.id != 'vimCodeElement".s:settings.id_suffix."')", | 623 \ "{", |
600 \ " {", | 624 \ " var lineNum;", |
601 \ " if (node.className == 'closed-fold')", | 625 \ " lineNum = window.location.hash;", |
602 \ " {", | 626 \ " lineNum = lineNum.substr(1); /* strip off '#' */", |
603 \ " /* toggle open the fold ID (remove window ID) */", | 627 \ "", |
604 \ " toggleFold(node.id.substr(4));", | 628 \ " if (lineNum.indexOf('L') == -1) {", |
605 \ " }", | 629 \ " lineNum = 'L'+lineNum;", |
606 \ " node = node.parentNode;", | |
607 \ " }", | 630 \ " }", |
631 \ " if (lineNum.indexOf('W') == -1) {", | |
632 \ " lineNum = 'W1'+lineNum;", | |
633 \ " }", | |
634 \ " var lineElem = document.getElementById(lineNum);" | |
608 \ ]) | 635 \ ]) |
609 endif | 636 endif |
610 call append(style_start, [ | |
611 \ "", | |
612 \ "/* function to open any folds containing a jumped-to line before jumping to it */", | |
613 \ "function JumpToLine()", | |
614 \ "{", | |
615 \ " var lineNum;", | |
616 \ " lineNum = window.location.hash;", | |
617 \ " lineNum = lineNum.substr(1); /* strip off '#' */", | |
618 \ "", | |
619 \ " if (lineNum.indexOf('L') == -1) {", | |
620 \ " lineNum = 'L'+lineNum;", | |
621 \ " }", | |
622 \ " if (lineNum.indexOf('W') == -1) {", | |
623 \ " lineNum = 'W1'+lineNum;", | |
624 \ " }", | |
625 \ " lineElem = document.getElementById(lineNum);" | |
626 \ ]) | |
627 | 637 |
628 " Insert javascript to toggle matching folds open and closed in all windows, | 638 " Insert javascript to toggle matching folds open and closed in all windows, |
629 " if dynamic folding is active. | 639 " if dynamic folding is active. |
630 if s:settings.dynamic_folds | 640 if s:settings.dynamic_folds |
631 call append(style_start, [ | 641 call append(style_start, [ |
646 \ " }", | 656 \ " }", |
647 \ " }", | 657 \ " }", |
648 \ ]) | 658 \ ]) |
649 endif | 659 endif |
650 | 660 |
651 " insert script tag; javascript is always needed for the line number | 661 if s:uses_script |
652 " normalization for URL hashes | 662 " insert script tag; javascript is always needed for the line number |
653 call append(style_start, [ | 663 " normalization for URL hashes |
654 \ "<script type='text/javascript'>", | 664 call append(style_start, [ |
655 \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"]) | 665 \ "<script type='text/javascript'>", |
666 \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"]) | |
667 endif | |
656 | 668 |
657 " Insert styles from all the generated html documents and additional styles | 669 " Insert styles from all the generated html documents and additional styles |
658 " for the table-based layout of the side-by-side diff. The diff should take | 670 " for the table-based layout of the side-by-side diff. The diff should take |
659 " up the full browser window (but not more), and be static in size, | 671 " up the full browser window (but not more), and be static in size, |
660 " horizontally scrollable when the lines are too long. Otherwise, the diff | 672 " horizontally scrollable when the lines are too long. Otherwise, the diff |
765 " set up expand_tabs option after all the overrides so we know the | 777 " set up expand_tabs option after all the overrides so we know the |
766 " appropriate defaults {{{ | 778 " appropriate defaults {{{ |
767 if user_settings.no_pre == 0 | 779 if user_settings.no_pre == 0 |
768 call tohtml#GetOption(user_settings, | 780 call tohtml#GetOption(user_settings, |
769 \ 'expand_tabs', | 781 \ 'expand_tabs', |
770 \ &expandtab || &ts != 8 || user_settings.number_lines || | 782 \ &expandtab || &ts != 8 || &vts != '' || user_settings.number_lines || |
771 \ (user_settings.dynamic_folds && !user_settings.no_foldcolumn)) | 783 \ (user_settings.dynamic_folds && !user_settings.no_foldcolumn)) |
772 else | 784 else |
773 let user_settings.expand_tabs = 1 | 785 let user_settings.expand_tabs = 1 |
774 endif | 786 endif |
775 " }}} | 787 " }}} |