X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/65072af318f7018583108e395d8b631f571bdaac..cf1290eb464f1256aa5c12d973fff774e4f83e5e:/doc/todo/format_escape.mdwn diff --git a/doc/todo/format_escape.mdwn b/doc/todo/format_escape.mdwn index 9d9942f20..762f16646 100644 --- a/doc/todo/format_escape.mdwn +++ b/doc/todo/format_escape.mdwn @@ -61,45 +61,43 @@ which aren't used as real extensions but provide useful intermediate types. >> rst. I am using this todo item somewhat as a pretext to get the conversion >> stuff in, which I need to implement some other stuff. As a result I was >> less careful with the rst plugin than with the rest of the patch. +>> I just updated the patch to fix some other problems which I found with +>> more testing, and document the current limitations. ->> This being said, as I understand it rst cannot embed raw html in ->> the middle of a paragraph. I just found with more tests that even ->> links are a bit tricky, and won't work if they're not surrounded by ->> whitespace; the problem is that if we add this space, links ->> and preprocessor directives at the beginning of a line will be indented, ->> and this means something to rst. Also, rst complains about "?" ->> being used multiple times when the page contains more than one broken link, ->> apparently it uses it as a name for the reference as well as the link text. +>> Rst cannot embed raw html in the middle of a paragraph, which is why +>> "_link" was necessary. Rst links are themselves tricky and can't be made to +>> work inside of words without knowledge about the context. +>> Both problems could be fixed by inserting marks instead of the html/link, +>> which would be replaced at a later stage (htmlize, format), somewhat +>> similiar to the way the toc plugin works. When I get more time I will +>> try to fix the remaining glitches this way. ->> The idea behind _link and other "intermediate ->> forms" was also that, when we can use rst's ability to target other output ->> formats, raw html won't be included in this process, and that ->> complications will happen with all markup languages if html continues ->> to be used as the language for preprocessor directive output. ->> Of course this could have been postponed until we actually need it, ->> but since we do... :-) +>> Also, I think it would be useful if ikiwiki had an option to export +>> the preprocessed source. This way you can use docutils to convert your +>> rst documents to other formats. Raw html would be loosed in such a +>> process (both with directives and marks), which is another +>> argument for `"_link"` and other intermediate forms. I think I can +>> come up with a way for rst's convert_link to be used only for export +>> purposes, though. ->> I think I will document the limitations, and tune the bugs of the ->> rst plugin code to do the most sensible thing after some more reading ->> of the rst docs. Expect an updated patch in the next few days, and feel ->> free to ask for other adjustments in the meantime. +>> --[[JeremieKoenig]] ->> Beyond being buggy in the least horrible way, I'm afraid I won't have ->> much time for ikiwiki in the next two or three weeks (exams), ->> but I think that ultimately these limitations could be worked around. ->> I'm not sure it is desirable for ikiwiki to know too much about the ->> syntax of its markup languages. Maybe the tricky "format" stuff ->> the toc plugin does could be used; maybe we need to think about more ->> generic ways to put "marks" in the various types of pages, which could ->> be expanded afer htmlization, and maybe the convert stuff could be used ->> to do this in an elegant way; ->> but then this is not very [[multiple_output_formats]] friendly either. ->> What do you think? +> Another problem with this approach is when there is some html (say a +> table), that contains a wikilink. If the link is left up to the markup +> lamguage to handle, it will never convert it to a link, since the table +> will be processed as a chunk of raw html. +> --[[Joey]] ->> --[[JeremieKoenig]] +### Updated patch + +I've created an updated [patch](http://www.idletheme.org/code/patches/ikiwiki-format-escapes-rlk-2007-09-24.diff) against the current revision. No real functionality changes, except for a small test script, one minor bugfix (put a "join" around a scalar-context "map" in convert_link), and some wrangling to get it merged properly; I thought it might be helpful for anyone else who wants to work on the code. + +(With that out of the way, I think I'm going to take a stab at Jeremie's plan to use marks which would be replaced post-htmlization. I've also got an eye towards [[todo/multiple_output_formats]].) + +--Ryan Koppenhaver ## Original patch -[[tag patch]] +[[!tag patch patch/core plugins/rst]]
Index: debian/changelog @@ -143,13 +141,13 @@ Index: IkiWiki/Plugin/rst.pm print html[html.find('')+6:html.find('')].strip(); "; - sub import { #{{{ + sub import { hook(type => "htmlize", id => "rst", call => \&htmlize); + hook(type => "htmlescape", id => "rst", call => \&htmlescape); + hook(type => "htmlescapelink", id => "rst", call => \&htmlescapelink); - } # }}} + } -+sub htmlescapelink ($$;@) { #{{{ ++sub htmlescapelink ($$;@) { + my $url = shift; + my $text = shift; + my %params = @_; @@ -160,15 +158,15 @@ Index: IkiWiki/Plugin/rst.pm + else { + return "`$text <$url>`_"; + } -+} # }}} ++} + -+sub htmlescape ($) { #{{{ ++sub htmlescape ($) { + my $html=shift; + $html=~s/^/ /mg; + return ".. raw:: html\n\n".$html; -+} # }}} ++} + - sub htmlize (@) { #{{{ + sub htmlize (@) { my %params=@_; my $content=$params{content}; Index: doc/plugins/write.mdwn @@ -220,8 +218,8 @@ Index: doc/plugins/rst.mdwn -* reStructuredText does not allow raw html to be inserted into - documents, but ikiwiki does so in many cases, including -- [[WikiLinks|WikiLink]] and many -- [[PreprocessorDirectives|PreprocessorDirective]]. +- [[WikiLinks|ikiwiki/WikiLink]] and many +- [[Directives|ikiwiki/Directive]]. +* Some bits of ikiwiki may still assume that markdown is used or embed html + in ways that break reStructuredText. (Report bugs if you find any.) * It's slow; it forks a copy of python for each page. While there is a @@ -274,7 +272,7 @@ Index: IkiWiki.pm + return $hooks{htmlescapelink}{$type}{call}->($bestlink, $linktext); + } return "$linktext"; - } #}}} + } @@ -628,6 +640,14 @@ preview => $preprocess_preview,