Mercurial > octave
annotate scripts/miscellaneous/private/__publish_latex_output__.m @ 24491:d8fb16ab0992
maint: move non-numeric m-files from general/ to miscellaneous/ dir.
* scripts/miscellaneous/fieldnames.m, scripts/miscellaneous/grabcode.m,
scripts/miscellaneous/inputParser.m, scripts/miscellaneous/isdir.m,
scripts/miscellaneous/loadobj.m, scripts/miscellaneous/methods.m,
scripts/miscellaneous/nargchk.m, scripts/miscellaneous/narginchk.m,
scripts/miscellaneous/nargoutchk.m, scripts/miscellaneous/nthargout.m,
scripts/miscellaneous/private/__publish_html_output__.m,
scripts/miscellaneous/private/__publish_latex_output__.m,
scripts/miscellaneous/publish.m, scripts/miscellaneous/saveobj.m,
scripts/miscellaneous/validateattributes.m: Moved from scripts/general dir.
* scripts/general/module.mk, scripts/miscellaneous/module.mk:
Update build system.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 28 Dec 2017 16:14:37 -0800 |
parents | scripts/general/private/__publish_latex_output__.m@1a0cbb573a67 |
children | 194eb4bd202b |
rev | line source |
---|---|
23188
e2e182a8e699
Allow custom output generators for code publishing.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23086
diff
changeset
|
1 ## Copyright (C) 2016-2017 Kai T. Ohlhus |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
2 ## |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
3 ## 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
|
4 ## |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
8 ## (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
|
9 ## |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
10 ## 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
|
11 ## 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
|
12 ## 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
|
13 ## 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
|
14 ## |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
15 ## 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
|
16 ## along with Octave; see the file COPYING. If not, see |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
18 |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
19 ## -*- texinfo -*- |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
20 ## @deftypefn {} {@var{outstr} =} __publish_latex_output__ (@var{type}, @var{varargin}) |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
21 ## |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
22 ## Internal function. |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
23 ## |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
24 ## 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
|
25 ## (@samp{str}) or cell-strings (@samp{cstr}) in @var{varargin} in order |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
26 ## to produce @LaTeX{} output. |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
27 ## |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
28 ## @var{type} is one of |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
29 ## |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
30 ## @itemize @bullet |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
31 ## @item |
23188
e2e182a8e699
Allow custom output generators for code publishing.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23086
diff
changeset
|
32 ## @samp{output_file_extension} () |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
33 ## |
23188
e2e182a8e699
Allow custom output generators for code publishing.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23086
diff
changeset
|
34 ## @item |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
35 ## @samp{header} (title_str, intro_str, toc_cstr) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
36 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
37 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
38 ## @samp{footer} () |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
39 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
40 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
41 ## @samp{code} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
42 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
43 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
44 ## @samp{code_output} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
45 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
46 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
47 ## @samp{section} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
48 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
49 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
50 ## @samp{preformatted_code} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
51 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
52 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
53 ## @samp{preformatted_text} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
54 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
55 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
56 ## @samp{bulleted_list} (cstr) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
57 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
58 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
59 ## @samp{numbered_list} (cstr) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
60 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
61 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
62 ## @samp{graphic} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
63 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
64 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
65 ## @samp{html} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
66 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
67 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
68 ## @samp{latex} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
69 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
70 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
71 ## @samp{text} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
72 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
73 ## @item |
23923
62dc81691d73
publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23565
diff
changeset
|
74 ## @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
|
75 ## |
62dc81691d73
publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23565
diff
changeset
|
76 ## @item |
62dc81691d73
publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23565
diff
changeset
|
77 ## @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
|
78 ## |
62dc81691d73
publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23565
diff
changeset
|
79 ## @item |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
80 ## @samp{bold} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
81 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
82 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
83 ## @samp{italic} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
84 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
85 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
86 ## @samp{monospaced} (str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
87 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
88 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
89 ## @samp{link} (url_str, url_str, str) |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
90 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
91 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
92 ## @samp{TM} () |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23188
diff
changeset
|
93 ## |
22781
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
94 ## @item |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
95 ## @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
|
96 ## |
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
97 ## @item |
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
98 ## @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
|
99 ## @end itemize |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
100 ## @end deftypefn |
449a5e84185a
doc: Add copyright notice and improve docstring.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22705
diff
changeset
|
101 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
102 function outstr = __publish_latex_output__ (type, varargin) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
103 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
|
104 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
105 |
23188
e2e182a8e699
Allow custom output generators for code publishing.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23086
diff
changeset
|
106 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
|
107 outstr = ".tex"; |
e2e182a8e699
Allow custom output generators for code publishing.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23086
diff
changeset
|
108 endfunction |
e2e182a8e699
Allow custom output generators for code publishing.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23086
diff
changeset
|
109 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
110 function outstr = do_header (title_str, intro_str, toc_cstr) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
111 publish_comment = sprintf ("%s\n", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
112 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
113 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
114 "% This document was generated by the publish-function", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
115 ["% from GNU Octave " version()], |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
116 ""); |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
117 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
118 latex_preamble = sprintf ("%s\n", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
119 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
120 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
121 '\documentclass[10pt]{article}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
122 '\usepackage{listings}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
123 '\usepackage{mathtools}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
124 '\usepackage{amssymb}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
125 '\usepackage{graphicx}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
126 '\usepackage{hyperref}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
127 '\usepackage{xcolor}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
128 '\usepackage{titlesec}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
129 '\usepackage[utf8]{inputenc}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
130 '\usepackage[T1]{fontenc}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
131 '\usepackage{lmodern}'); |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
132 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
133 listings_option = sprintf ("%s\n", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
134 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
135 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
136 '\lstset{', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
137 'language=Octave,', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
138 'numbers=none,', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
139 'frame=single,', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
140 'tabsize=2,', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
141 'showstringspaces=false,', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
142 'breaklines=true}'); |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
143 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
144 latex_head = sprintf ("%s\n", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
145 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
146 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
147 '\titleformat*{\section}{\Huge\bfseries}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
148 '\titleformat*{\subsection}{\large\bfseries}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
149 '\renewcommand{\contentsname}{\Large\bfseries Contents}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
150 '\setlength{\parindent}{0pt}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
151 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
152 '\begin{document}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
153 "", |
23964
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
154 ['{\Huge\section*{' title_str '}}'], |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
155 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
156 '\tableofcontents', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
157 '\vspace*{4em}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
158 ""); |
22157
c5842206aaea
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22113
diff
changeset
|
159 |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
160 outstr = [publish_comment, latex_preamble, listings_option, latex_head]; |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
161 |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
162 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
163 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
164 function outstr = do_footer (m_source_str) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
165 outstr = ["\n\n" '\end{document}' "\n"]; |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
166 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
167 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
168 function outstr = do_code (str) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
169 outstr = ['\begin{lstlisting}' "\n", str, "\n" '\end{lstlisting}' "\n"]; |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
170 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
171 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
172 function outstr = do_code_output (str) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
173 outstr = sprintf ("%s\n", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
174 '\begin{lstlisting}[language={},xleftmargin=5pt,frame=none]', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
175 str, |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
176 '\end{lstlisting}'); |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
177 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
178 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
179 function outstr = do_section (str) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
180 outstr = sprintf ("%s\n", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
181 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
182 "", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
183 '\phantomsection', |
23964
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
184 ['\addcontentsline{toc}{section}{' str '}'], |
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
185 ['\subsection*{' str '}'], |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
186 ""); |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
187 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
188 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
189 function outstr = do_preformatted_code (str) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
190 outstr = sprintf ("%s\n", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
191 '\begin{lstlisting}', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
192 str, |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
193 '\end{lstlisting}'); |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
194 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
195 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
196 function outstr = do_preformatted_text (str) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
197 outstr = sprintf ("%s\n", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
198 '\begin{lstlisting}[language={}]', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
199 str, |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
200 '\end{lstlisting}'); |
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:
22384
diff
changeset
|
203 function outstr = do_bulleted_list (cstr) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
204 outstr = ["\n" '\begin{itemize}' "\n"]; |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
205 for i = 1:numel (cstr) |
23964
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
206 outstr = [outstr, '\item ' cstr{i} "\n"]; |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
207 endfor |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
208 outstr = [outstr, '\end{itemize}' "\n"]; |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
209 endfunction |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
210 |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
211 function outstr = do_numbered_list (cstr) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
212 outstr = ["\n" '\begin{enumerate}' "\n"]; |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
213 for i = 1:numel (cstr) |
23964
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
214 outstr = [outstr, '\item ' cstr{i} "\n"]; |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
215 endfor |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
216 outstr = [outstr, "\\end{enumerate}\n"]; |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
217 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
218 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
219 function outstr = do_graphic (str) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
220 outstr = sprintf ("%s\n", |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
221 '\begin{figure}[!ht]', |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
222 ['\includegraphics[width=\textwidth]{' str '}'], |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
223 '\end{figure}'); |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
224 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
225 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
226 function outstr = do_html (str) |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
227 outstr = ""; |
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:
22384
diff
changeset
|
230 function outstr = do_latex (str) |
23926
58b76c741c3d
publish: improve detecion of block markup (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23923
diff
changeset
|
231 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
|
232 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
233 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
234 function outstr = do_link (url_str, str) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
235 outstr = ['\href{' url_str '}{' str '}']; |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
236 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
237 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
238 function outstr = do_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
|
239 outstr = ["\n\n" str "\n\n"]; |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
240 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
241 |
23923
62dc81691d73
publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23565
diff
changeset
|
242 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
|
243 outstr = ["$$" str "$$"]; |
62dc81691d73
publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23565
diff
changeset
|
244 endfunction |
62dc81691d73
publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23565
diff
changeset
|
245 |
62dc81691d73
publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23565
diff
changeset
|
246 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
|
247 outstr = ["$" str "$"]; |
62dc81691d73
publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23565
diff
changeset
|
248 endfunction |
62dc81691d73
publish: improve detection of inline markup and fix MathJax usage.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23565
diff
changeset
|
249 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
250 function outstr = do_bold (str) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
251 outstr = ['\textbf{' str '}']; |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
252 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
253 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
254 function outstr = do_italic (str) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
255 outstr = ['\textit{' str '}']; |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
256 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
257 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
258 function outstr = do_monospaced (str) |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
259 outstr = ['\texttt{' str '}']; |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
260 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
261 |
22705
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
262 function outstr = do_TM () |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
263 outstr = '\texttrademark '; |
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:
22384
diff
changeset
|
266 function outstr = do_R () |
e9a0aa0a49ed
Overhaul publish function and it's private helper functions.
Rik <rik@octave.org>
parents:
22384
diff
changeset
|
267 outstr = '\textregistered '; |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
268 endfunction |
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
269 |
23964
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
270 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
|
271 ## Escape \, {, }, &, %, #, _, ~, ^, <, > |
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
272 str = regexprep (str, '\\', "\\ensuremath{\\backslash}"); |
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
273 str = regexprep (str, '(?<!\\)(\{|\}|&|%|#|_)', '\\$1'); |
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
274 ## Revert accidential {} replacements for backslashes |
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
275 str = strrep (str, '\ensuremath\{\backslash\}', '\ensuremath{\backslash}'); |
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
276 str = regexprep (str, '(?<!\\)~', "\\ensuremath{\\tilde{\\;}}"); |
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
277 str = regexprep (str, '(?<!\\)\^', "\\^{}"); |
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
278 str = regexprep (str, '(?<!\\)<', "\\ensuremath{<}"); |
1a0cbb573a67
publish: Improve escaping of special characters in output (bug #51782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23926
diff
changeset
|
279 str = regexprep (str, '(?<!\\)>', "\\ensuremath{>}"); |
22113
b6f482e29afd
New functions publish.m and grabcode.m (patch #9048).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
diff
changeset
|
280 endfunction |