-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem.txt
127 lines (74 loc) · 4.75 KB
/
problem.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Problems and solutions
======================
[[Parent]]: user_documentation.txt
This section contains some problems that you might run into when using
Remark, and the solutions of those problems.
[[set Code.type]]: javascript
Code and mathematics
--------------------
### Problem
Consider the following example:
[[Example]]:
$a + `b$ $c` + d$
`a + $b` `c$ + d`
Ideally, the first paragraph would be interpreted as two subsequent math expressions with backtick-symbols, and the second paragraph as two subsequent code segments with dollar-symbols. While the latter works, the former is interpreted as a single math expression.
### Diagnosis
The problem lies deep in Python Markdown, which parses inline-patterns --- such as code and mathematics --- sequentially. This means that one or the other has to be parsed first --- there is no context-sensitivity. We chose to parse the backticks before mathematics, to not change the behaviour of Markdown backticks.
The backticks in the first paragraph creates a `<code>` tag around the content in the backticks --- embedded into a math expression. Since this does not make sense, we replace the `<code>` tag with its text. While this recovers the use of _paired_ backticks in math expressions, single backticks remain a problem, as demonstrated in the example.
### Solution
Ideally, the inline-patterns would be parsed recursively, from outside to inside. Then the outside pattern would get to decide how to treat its content (here as raw text). This is unlikely to be fixed in Python Markdown.
At some point we will replace Python Markdown with a dedicated parser for Remark, which solves this problem as well as many others.
Indentation macro is too eager
------------------------------
### Problem
In the following, the content of the list-item is meant to continue after the empty line. However, since the latter is indented _with a tab_, Remark interprets this as a list-item followed by an invocation of the indentation macro.
[[Example]]:
* This is in the list-item.
This is also meant to be in the list-item.
### Solution
Use _spaces_ instead of tabs for Markdown-related indentation.
[[Example]]:
* This is in the list-item.
This is also meant to be in the list-item.
Or, indent the first non-empty row preceding the invocation of the indentation macro.
[[Example]]:
*
This is in the list-item.
This is also meant to be in the list-item.
SVG-image does not get loaded
-----------------------------
### Problem
An SVG-image does not get loaded when a Remark-generated html-file is run from a server, but does get loaded when it is run from the hard-disk.
### Solution (probable)
The probable cause is that the server does not have the MIME-type correctly assigned for the `.svg` files.
For example, for the `lighttpd` web-server, the configuration file `/etc/lighttpd/mime-types.conf` should be modified to contain the line
".svg" => "image/svg+xml"
The former string is the file-extension of the SVG-image file format, while the latter is its MIME-type.
Files that are not UTF-8 encoded
--------------------------------
If you pass Remark a file that is not a valid UTF-8 encoding, Remark replaces each erroneous symbol with � (U+FFFD REPLACEMENT CHARACTER).
Indentation-macro invocation after a multi-line parameter
---------------------------------------------------------
### Problem
It is wanted to write an indentation macro after invoking a macro with a multi-line parameter. However, Remark interprets the parameter for the indentation macro to be part of the preceding macro-invocation.
### Solution
Indentation has a double role. It is used both to denote the [invocation][MacroInvocation] of the indentation macro, and to denote the range of a multi-line parameter for a macro. Therefore, if one wants to write an indentation macro-invocation directly after a multi-line parameter, there must be some way to tell Remark where the multi-line parameter ends and the indentation macro-invocation starts.
The immediate solution to this problem is to use explicit invocation instead. However, if the used indentation macro is not known to the writer (e.g. it is generated by some automated process), this solution is not applicable. A general solution is to use the [Comment][CommentMacro] macro without a multi-line parameter to divide the parameters.
### Example
[[Example]]:
[[CppCode]]:
int square(int x)
{
return x * x;
}
int cube(int x)
{
return x * x * x;
}
[[Comment]]
Parameters for indentation macro-invocation here.
[CommentMacro]: [[Ref]]: Comment_Macro.txt
[MacroInvocation]: [[Ref]]: macro_invocation.txt
Injecting html to the head section
----------------------------------
Html-code can be injected into the head-section of a html-file by storing text in the `html_head` tag.