Fix table and line breaks in man pages
Loïc Hoguin
5 years ago
81 | 81 | io:format("Ignored AST node ~p~n", [Node]), |
82 | 82 | [] |
83 | 83 | end |
84 | catch _:_ -> | |
85 | io:format("Ignored AST node ~p~n", [Node]), | |
84 | catch C:E -> | |
85 | io:format("Ignored AST node ~p~nReason: ~p:~p~nStacktrace: ~p~n", | |
86 | [Node, C, E, erlang:get_stacktrace()]), | |
86 | 87 | [] |
87 | 88 | end. |
88 | 89 | |
168 | 169 | |
169 | 170 | %% @todo Currently acts as if options="headers" was always set. |
170 | 171 | table_apply_options([{row, RAttrs, Headers0, RAnn}|Tail]) -> |
171 | Headers = [{cell, CAttrs, [{strong, #{}, CText, CAnn}], CAnn} | |
172 | Headers = [{cell, CAttrs#{style => <<"strong">>}, CText, CAnn} | |
172 | 173 | || {cell, CAttrs, CText, CAnn} <- Headers0], |
173 | 174 | [{row, RAttrs, Headers, RAnn}|Tail]. |
174 | 175 | |
177 | 178 | || {row, _, Cells, _} <- Rows]. |
178 | 179 | |
179 | 180 | table_style_cells(Cells) -> |
180 | ["lt " || {cell, _, _, _} <- Cells]. | |
181 | [case CAttrs of | |
182 | #{style := <<"strong">>} -> "ltb "; | |
183 | _ -> "lt " | |
184 | end || {cell, CAttrs, _, _} <- Cells]. | |
181 | 185 | |
182 | 186 | table_contents(Rows) -> |
183 | 187 | [[table_contents_cells(Cells), "\n"] |
187 | 191 | [table_contents_cell(FirstCell), |
188 | 192 | [[":", table_contents_cell(Cell)] || Cell <- Cells]]. |
189 | 193 | |
190 | table_contents_cell({cell, _, Text, _}) -> | |
194 | table_contents_cell({cell, _, [{paragraph, _, Text, _}], _}) -> | |
191 | 195 | ["T{\n", inline(Text), "\nT}"]. |
192 | 196 | |
193 | 197 | %% Comment lines are printed in the generated file |
218 | 222 | %% Xref links appear as plain text in manuals. |
219 | 223 | inline({xref, _, Text, _}) -> |
220 | 224 | inline(Text); |
225 | inline({line_break, _, _, _}) -> | |
226 | "\n.br\n"; | |
221 | 227 | inline(Text) when is_list(Text) -> |
222 | 228 | [inline(T) || T <- Text]. |