annotate scripts/miscellaneous/private/__publish_html_output__.m @ 31593:0f93c3a756f7 stable

doc: grammarcheck documentation ahead of 8.1 release. * interpreter.cc, load-path.cc, warning_ids.m, __memoize__.m, print.m: grammarcheck documentation ahead of 8.1 release.
author Rik <rik@octave.org>
date Tue, 29 Nov 2022 15:58:49 -0800
parents 939e69b45601
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30379
diff changeset
3 ## Copyright (C) 2016-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
7 ##
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
8 ## This file is part of Octave.
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24491
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24491
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
13 ## (at your option) any later version.
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
14 ##
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
18 ## GNU General Public License for more details.
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
19 ##
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
20 ## You should have received a copy of the GNU General Public License
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24491
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
25
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
26 ## -*- texinfo -*-
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
27 ## @deftypefn {} {@var{outstr} =} __publish_html_output__ (@var{type}, @var{varargin})
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
28 ##
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
29 ## Internal function.
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
30 ##
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
31 ## The first input argument @var{type} defines the required strings
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
32 ## (@samp{str}) or cell-strings (@samp{cstr}) in @var{varargin} in order
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
33 ## to produce HTML output.
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
34 ##
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
35 ## @var{type} is one of
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
36 ##
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
37 ## @itemize @bullet
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
38 ## @item
23188
e2e182a8e699 Allow custom output generators for code publishing.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23086
diff changeset
39 ## @samp{output_file_extension} ()
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
40 ##
23188
e2e182a8e699 Allow custom output generators for code publishing.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23086
diff changeset
41 ## @item
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
42 ## @samp{header} (title_str, intro_str, toc_cstr)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
43 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
44 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
45 ## @samp{footer} ()
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
46 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
47 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
48 ## @samp{code} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
49 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
50 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
51 ## @samp{code_output} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
52 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
53 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
54 ## @samp{section} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
55 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
56 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
57 ## @samp{preformatted_code} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
58 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
59 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
60 ## @samp{preformatted_text} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
61 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
62 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
63 ## @samp{bulleted_list} (cstr)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
64 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
65 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
66 ## @samp{numbered_list} (cstr)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
67 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
68 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
69 ## @samp{graphic} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
70 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
71 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
72 ## @samp{html} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
73 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
74 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
75 ## @samp{latex} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
76 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
77 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
78 ## @samp{text} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
79 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
80 ## @item
23923
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
81 ## @samp{blockmath} (str)
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
82 ##
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
83 ## @item
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
84 ## @samp{inlinemath} (str)
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
85 ##
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
86 ## @item
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
87 ## @samp{bold} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
88 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
89 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
90 ## @samp{italic} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
91 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
92 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
93 ## @samp{monospaced} (str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
94 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
95 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
96 ## @samp{link} (url_str, url_str, str)
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
97 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
98 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
99 ## @samp{TM} ()
23565
3a730821e4a2 doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents: 23188
diff changeset
100 ##
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
101 ## @item
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
102 ## @samp{R} ()
23964
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
103 ##
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
104 ## @item
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
105 ## @samp{escape_special_chars} (str)
22781
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
106 ## @end itemize
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
107 ## @end deftypefn
449a5e84185a doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22705
diff changeset
108
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
109 function outstr = __publish_html_output__ (type, varargin)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
110 outstr = feval (["do_" type], varargin{:});
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
111 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
112
23188
e2e182a8e699 Allow custom output generators for code publishing.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23086
diff changeset
113 function outstr = do_output_file_extension ()
e2e182a8e699 Allow custom output generators for code publishing.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23086
diff changeset
114 outstr = ".html";
e2e182a8e699 Allow custom output generators for code publishing.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23086
diff changeset
115 endfunction
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
116
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
117 function outstr = do_header (title_str, intro_str, toc_cstr)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29358
diff changeset
118
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
119 mathjax_str = sprintf ("%s\n",
30592
939e69b45601 publish.m: Update URLs.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 30564
diff changeset
120 "<script>",
939e69b45601 publish.m: Update URLs.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 30564
diff changeset
121 "MathJax = {",
939e69b45601 publish.m: Update URLs.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 30564
diff changeset
122 " tex: {",
939e69b45601 publish.m: Update URLs.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 30564
diff changeset
123 " inlineMath: [['$','$'], ['\\\\(','\\\\)']],",
939e69b45601 publish.m: Update URLs.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 30564
diff changeset
124 " tags: 'all'",
939e69b45601 publish.m: Update URLs.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 30564
diff changeset
125 " }",
939e69b45601 publish.m: Update URLs.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 30564
diff changeset
126 "};",
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
127 "</script>",
30592
939e69b45601 publish.m: Update URLs.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 30564
diff changeset
128 '<script type="text/javascript" async ',
939e69b45601 publish.m: Update URLs.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 30564
diff changeset
129 'src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">',
939e69b45601 publish.m: Update URLs.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 30564
diff changeset
130 "</script>");
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
131
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
132 stylesheet_str = sprintf ("%s\n",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
133 "<style>",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
134 "body > * {",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
135 " max-width: 42em;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
136 "}",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
137 "body {",
24376
0755de78071c Fix quoting error from cset b1d1229d9e83.
Rik <rik@octave.org>
parents: 24370
diff changeset
138 ' font-family: "Roboto Condensed", sans-serif;',
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
139 " padding-left: 7.5em;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
140 " padding-right: 7.5em;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
141 "}",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
142 "pre, code {",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
143 " max-width: 50em;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
144 " font-family: monospace;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
145 "}",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
146 "pre.oct-code {",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
147 " border: 1px solid Grey;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
148 " padding: 5px;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
149 "}",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
150 "pre.oct-code-output {",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
151 " margin-left: 2em;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
152 "}",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
153 "span.comment {",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
154 " color: ForestGreen;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
155 "}",...
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
156 "span.keyword {",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
157 " color: Blue;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
158 "}",...
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
159 "span.string {",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
160 " color: DarkOrchid;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
161 "}",...
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
162 "footer {",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
163 " margin-top: 2em;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
164 " font-size: 80%;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
165 "}",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
166 "a, a:visited {",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
167 " color: Blue;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
168 "}",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
169 "h2 {",
24376
0755de78071c Fix quoting error from cset b1d1229d9e83.
Rik <rik@octave.org>
parents: 24370
diff changeset
170 ' font-family: "Roboto Condensed", serif;',
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
171 " margin-top: 1.5em;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
172 "}",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
173 "h2 a, h2 a:visited {",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
174 " color: Black;",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
175 "}",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
176 "</style>");
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
177
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
178 outstr = sprintf ("%s\n",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
179 "<!DOCTYPE html>",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
180 "<html>",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
181 "<head>",
24370
b1d1229d9e83 maint: Use single quotes to simplify excessive backslash escapes in code.
Rik <rik@octave.org>
parents: 23964
diff changeset
182 '<meta charset="UTF-8">',
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
183 ["<title>" title_str "</title>"],
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
184 mathjax_str,
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
185 stylesheet_str,
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
186 "</head>",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
187 "<body>",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
188 ["<h1>" title_str "</h1>"],
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
189 intro_str);
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
190
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
191 if (! isempty (toc_cstr))
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
192 for i = 1:numel (toc_cstr)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
193 toc_cstr{i} = do_link (["#node" sprintf("%d", i)], toc_cstr{i});
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
194 endfor
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
195 outstr = [outstr, "<h2>Contents</h2>", do_bulleted_list(toc_cstr)];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
196 endif
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
197
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
198 ## Reset section counter
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
199 do_section ();
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
200
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
201 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
202
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
203 function outstr = do_footer (m_source_str)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29358
diff changeset
204
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
205 outstr = sprintf ("%s\n",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
206 "",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
207 "<footer>",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
208 "<hr>",
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24534
diff changeset
209 ['<a href="https://www.octave.org">Published with GNU Octave ' version() '</a>'],
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
210 "</footer>",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
211 "<!--",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
212 "##### SOURCE BEGIN #####",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
213 m_source_str,
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
214 "##### SOURCE END #####",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
215 "-->",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
216 "</body>",
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
217 "</html>");
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29358
diff changeset
218
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
219 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
220
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
221 function outstr = do_code (str)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
222 outstr = ["\n", '<pre class="oct-code">' syntax_highlight(str) "</pre>\n"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
223 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
224
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
225 function outstr = do_code_output (str)
23964
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
226 str = do_escape_special_chars (str);
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
227 outstr = ["\n", '<pre class="oct-code-output">' str "</pre>\n"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
228 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
229
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
230 function outstr = do_section (varargin)
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
231 persistent counter = 1;
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
232
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
233 if (nargin == 0)
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
234 outstr = "";
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
235 counter = 1;
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
236 return;
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
237 endif
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
238
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
239 outstr = ['<h2><a id="node' sprintf("%d", counter) '">', ...
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
240 varargin{1}, ...
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
241 "</a></h2>"];
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
242
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
243 counter++;
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
244
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
245 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
246
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
247 function outstr = do_preformatted_code (str)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
248 outstr = ["\n", '<pre class="pre-code">' syntax_highlight(str) "</pre>\n"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
249 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
250
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
251 function outstr = do_preformatted_text (str)
23964
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
252 str = do_escape_special_chars (str);
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
253 outstr = ["\n", '<pre class="pre-text">' str "</pre>\n"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
254 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
255
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
256 function outstr = do_bulleted_list (cstr)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29358
diff changeset
257
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
258 outstr = "\n<ul>\n";
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
259 for i = 1:numel (cstr)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
260 outstr = [outstr, "<li>" cstr{i} "</li>\n"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
261 endfor
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
262 outstr = [outstr, "</ul>\n"];
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29358
diff changeset
263
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
264 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
265
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
266 function outstr = do_numbered_list (cstr)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29358
diff changeset
267
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
268 outstr = "\n<ol>\n";
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
269 for i = 1:numel (cstr)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
270 outstr = [outstr, "<li>" cstr{i} "</li>\n"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
271 endfor
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
272 outstr = [outstr, "</ol>\n"];
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29358
diff changeset
273
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
274 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
275
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
276 function outstr = do_graphic (str)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
277 outstr = ['<img src="' str '" alt="' str '">'];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
278 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
279
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
280 function outstr = do_html (str)
23926
58b76c741c3d publish: improve detecion of block markup (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23923
diff changeset
281 outstr = ["\n" str "\n"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
282 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
283
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
284 function outstr = do_latex (str)
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
285 outstr = "";
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
286 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
287
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
288 function outstr = do_link (url_str, str)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
289 outstr = ['<a href="' url_str '">' str "</a>"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
290 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
291
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
292 function outstr = do_text (str)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
293 outstr = ["\n<p>" str "</p>\n"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
294 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
295
23923
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
296 function outstr = do_blockmath (str)
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
297 outstr = ["$$" str "$$"];
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
298 endfunction
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
299
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
300 function outstr = do_inlinemath (str)
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
301 outstr = ["$" str "$"];
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
302 endfunction
62dc81691d73 publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23565
diff changeset
303
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
304 function outstr = do_bold (str)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
305 outstr = ["<b>" str "</b>"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
306 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
307
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
308 function outstr = do_italic (str)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
309 outstr = ["<i>" str "</i>"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
310 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
311
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
312 function outstr = do_monospaced (str)
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
313 outstr = ["<code>" str "</code>"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
314 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
315
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
316 function outstr = do_TM ()
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
317 outstr = "&trade;";
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
318 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
319
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
320 function outstr = do_R ()
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
321 outstr = "&reg;";
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
322 endfunction
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
323
23964
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
324 function str = do_escape_special_chars (str)
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
325 str = regexprep (str, '&', '&amp;');
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
326 str = regexprep (str, '<', '&lt;');
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
327 str = regexprep (str, '>', '&gt;');
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
328 ## str = regexprep (str, '"', '&quot;'); ## MATLAB R2017a compatibility.
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
329 endfunction
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
330
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
331 ## SYNTAX_HIGHLIGHT: A primitive parser to highlight syntax via <span> tags.
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
332 ## FIXME: Needs to be replaced by a better solution.
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
333 function outstr = syntax_highlight (str)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29358
diff changeset
334
23964
1a0cbb573a67 publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 23926
diff changeset
335 str = do_escape_special_chars (str);
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
336 outstr = "";
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
337 placeholder_cstr = {};
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
338 i = 1;
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
339 plh = 0;
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
340
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
341 while (i <= numel (str))
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
342 ## Block comment
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
343 if (any (strncmp (str(i:end), {"%{", "#{"}, 2)))
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
344 plh_str = ['<span class="comment">', str(i:i+1)];
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
345 i += 2;
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
346 while (i <= numel (str)
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
347 && ! (any (strncmp (str(i:end), {"%}", "#}"}, 2))))
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
348 plh_str = [plh_str, str(i)];
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
349 i += 1;
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
350 endwhile
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
351 if (i < numel (str))
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
352 plh_str = [plh_str, str(i:i+1), "</span>"];
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
353 i += 2;
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
354 else
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
355 plh_str = [plh_str, "</span>"];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
356 endif
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
357 plh += 1;
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
358 placeholder_cstr{plh} = plh_str;
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
359 outstr = [outstr, " PUBLISHPLACEHOLDER", sprintf("%d", plh), " "];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
360 ## Line comment
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
361 elseif (str(i) == "#" || str(i) == "%")
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
362 plh_str = '<span class="comment">';
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
363 idx = find (str(i:end) == "\n", 1);
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
364 if (isempty (idx))
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
365 plh_str = [plh_str, str(i:end)];
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
366 i = numel (str) + 1;
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
367 else
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
368 plh_str = [plh_str, str(i:i+idx-2)];
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
369 i += idx;
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
370 endif
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
371 plh_str = [plh_str, "</span>\n"];
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
372 plh += 1;
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
373 placeholder_cstr{plh} = plh_str;
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
374 outstr = [outstr, " PUBLISHPLACEHOLDER", sprintf("%d", plh), " "];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
375 ## Single quoted string
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
376 elseif (str(i) == "'")
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
377 plh_str = "<span class=\"string\">'";
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
378 i += 1;
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
379 while (i <= numel (str))
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
380 ## Ignore escaped string terminations
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
381 if (strncmp (str(i:end), "''", 2))
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
382 plh_str = [plh_str, "''"];
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
383 i += 2;
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
384 ## Is char a string termination?
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
385 elseif (str(i) == "'")
22685
b8c5280be6ad __publish_html_output__.m: Ensure </span> in any case in syntax highlighting.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22674
diff changeset
386 plh_str = [plh_str, "'"];
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
387 i += 1;
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
388 break;
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
389 ## Is string terminated by line break?
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
390 elseif (str(i) == "\n")
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
391 break;
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
392 ## String content
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
393 else
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
394 plh_str = [plh_str, str(i)];
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
395 i += 1;
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
396 endif
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
397 endwhile
22685
b8c5280be6ad __publish_html_output__.m: Ensure </span> in any case in syntax highlighting.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22674
diff changeset
398 plh_str = [plh_str, "</span>"];
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
399 plh += 1;
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
400 placeholder_cstr{plh} = plh_str;
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
401 outstr = [outstr, " PUBLISHPLACEHOLDER", sprintf("%d", plh), " "];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
402 ## Double quoted string
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
403 elseif (str(i) == '"')
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
404 plh_str = '<span class="string">"';
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
405 i += 1;
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
406 while (i <= numel (str))
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
407 ## Is char a string termination?
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
408 if (str(i) == '"' && str(i-1) != '\')
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
409 plh_str = [plh_str, '"'];
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
410 i += 1;
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
411 break;
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
412 ## Is string terminated by line break?
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
413 elseif (str(i) == "\n")
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
414 break;
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
415 ## String content
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
416 else
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
417 plh_str = [plh_str, str(i)];
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
418 i += 1;
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
419 endif
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
420 endwhile
22685
b8c5280be6ad __publish_html_output__.m: Ensure </span> in any case in syntax highlighting.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22674
diff changeset
421 plh_str = [plh_str, "</span>"];
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
422 plh += 1;
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
423 placeholder_cstr{plh} = plh_str;
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
424 outstr = [outstr, " PUBLISHPLACEHOLDER", sprintf("%d", plh), " "];
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
425 else
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
426 outstr = [outstr, str(i)];
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
427 i += 1;
22113
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
428 endif
b6f482e29afd New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff changeset
429 endwhile
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
430
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
431 persistent kword_ptn = strjoin (iskeyword (), '|');
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
432
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
433 ## FIXME: remove hack for regexprep once bug #38149 is solved
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
434 outstr = [" ", strrep(outstr, "\n", " \n "), " "];
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
435 outstr = regexprep (outstr,
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
436 ['(\s)(' kword_ptn ')(\s|\()'],
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
437 ['$1<span class="keyword">$2</span>$3']);
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
438 ## FIXME: remove hack for regexprep once bug #38149 is solved
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
439 outstr = strrep (outstr(2:end-1), " \n ", "\n");
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
440
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
441 ## Restore placeholders
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
442 for i = plh:-1:1
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
443 outstr = strrep (outstr, [" PUBLISHPLACEHOLDER", sprintf("%d", i), " "],
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
444 placeholder_cstr{i});
22674
c024fb103114 minor improvements for publish.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22384
diff changeset
445 endfor
22705
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
446
e9a0aa0a49ed Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents: 22685
diff changeset
447 endfunction