[wp-hackers] Text Flow & Markdown
Michel Fortin
michel.fortin at michelf.com
Wed Jun 1 15:15:51 GMT 2005
Le 1 juin 2005, à 10:47, Jonathan Leighton a écrit :
> Michel Fortin wrote:
>
>> <http://www.michelf.com/weblog/2005/wordpress-text-flow-vs-markdown/>
>
> This is an excellent post... especially the diagram which is very
> useful. Could something be done for more consistency with the text
> processing? (As outlined in the post).
I think one of the problems is that the WordPress filter system is made
to work with some kind of HTML-without-<p>-tag format. It is assumed
that paragraphs are added at the end of the process, just before
showing it on the page. This is what causes trouble, because Markdown,
Textile, and most other syntaxes just can't dissociate that step from
the other transformation step that lead to HTML.
I think the best way to solve this in the long run is to draw a line in
the text flow chart and say: "Above that line, it's the user custom
syntax; below that line it's some HTML *with paragraph tags*". On that
line there is a filter that makes the translation from a user syntax to
HTML. (By default the user syntax is that HTML-without-<p>-tag format
and the filter on the line is `wpautop`.) On the HTML side, other
filters can balance tags at will, filter undesirable tags, strip all of
them, add/remove/change attributes and make smart quotes. But this must
not be done before the syntax has been converted to HTML -- and I mean
HTML *with paragraphs* -- by `wpautop` or another filter.
Because WordPress does not work that way, Markdown has to change it to
work like that with some nasty tricks, or else some syntax elements do
not work correctly.
* * *
So here comes my suggestions.
First, there are some holes in the hooks available. There is a
`get_the_excerpt` hook, but no `get_the_content` and no
`get_the_title`. I think they should be added.
Second, reserve `get_the_*` for static filters. This means the filter
do not take into account anything relating to the incoming request. For
example, this would include `wautop`, but not the Google hilite filter.
Dynamic filters would say in `the_*` hooks. This will add some
coherence and symmetry to the text flow and will allow plugins like
[PreFormatted][1] to coexist peacefully with Google hilite and PHPExec.
[1]: http://vapourtrails.ca/wp-preformatted
Third, specify a priority level inside `get_the_*` hook which will be
the line of separation between user syntax and HTML. The priority
number should leave some space before and after it for user syntax
add-ons from other plugins. (I'm thinking about [LazyImageLayout][2]
here.)
[2]: http://www.davidseah.com/archives/2004/09/26/lzil02/
I'm still not sure about what could be done about `balanceTags` in
`*_save_pre` hooks and about comment filters.
Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/
More information about the wp-hackers
mailing list