Re: Feature Request External label resolution
Allan Odgaard wrote: On 20 Apr 2008, at 00:28, Sherwood Botsford wrote: [...] Suppose that markdown was clever enough to reference an external file (in .markdownrc of course) for the resolution of LABEL. Here’s a simple shell script to convert all markdown to HTML and using a shared references file: cd ~/MySite/pages for f in *.mdown; do cat $f references|Markdown.pl ../html/${f%.mdown}.html done I use something like that myself where I also have a command to update my references list, that is, grep through the pages for undefined references and add these to the references file (where I will then need to add the URI). Hmm. Ok, I think I could to it this way in Template Toolkit: [% INCLUDE Header.inc %] ]% USE Markdown %] [% FILTER Markdown %] div class=content blah blah blah /div [% INSERT References.inc %] [% END %] [% INCLUDE Footer.inc %] Downside is then that Markdown has to process every reference which if you have a few thousand will be time consuming. (I have an INSERT text at one point that jsut in template toolkit takes 10-12 seconds to do. It's only a thousand lines, but there is zero processing to do, it just stuffs it into the file. ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss
Re: Feature Request External label resolution
On 20 Apr 2008, at 07:11, Sherwood Botsford wrote: Hmm. Ok, I think I could to it this way in Template Toolkit: snip Downside is then that Markdown has to process every reference which if you have a few thousand will be time consuming. (I have an INSERT text at one point that jsut in template toolkit takes 10-12 seconds to do. It's only a thousand lines, but there is zero processing to do, it just stuffs it into the file. If you're prepared to have a fiddle with perl, have a look at Text::Markdown (on CPAN).. You can do this reasonably trivially - here is a ghetto version of Markdown.pl which will suck all your link references out of ~/.markdownrc: use strict; use warnings; use Text::Markdown; use File::Slurp; use File::HomeDir; use Path::Class; my $m = Text::Markdown-new; my $urls; { my $markdownrc = read_file(file(File::HomeDir-my_home, '.markdownrc')); $m-markdown($markdownrc); $urls = $m-{_urls}; } print $m-markdown(, {urls = $urls}); That should do what you originally asked for - adjust to taste.. If you wanted to add an accessor for the URLs hashref on the module, and an option to the Markdown.pl script that I bundle in the distribution to give it this functionality, I'd be very happy to take a patch. :_) Cheers Tom ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss
Re: Feature Request External label resolution
Pandoc concatenates input from all files specified on the command line. So you can just do: pandoc myfile.txt refs.txt myfile.html Seems to me that this would be a reasonable default behavior for Markdown.pl as well, but it doesn't seem to work that way now. John +++ Sherwood Botsford [Apr 19 08 16:28 ]: One of the things I'm coming up against. Maintaining a non-small web site with many internal links is a pain. Consider: Suppose that at one point I have site/ Images Business Home ... Later the site gets more complex, and Images has a bunch of sub directories. site/ Images header_rotate inventory_pix misc Business Home When this happens I have to change the link for every pic on every page. If I use an image in 6 places, I have to change it in 6 places. HOWEVER Suppose I cleverly used the footnote form of links. I.e: [Image alt text][LABEL] Suppose that markdown was clever enough to reference an external file (in .markdownrc of course) for the resolution of LABEL. NOW when I re-arrange the universe, I only have to change the reference in this one file, NOT in every file that references it. ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss
Re: Feature Request External label resolution
You could do something like: cat myfile.txt refs.txt | MultiMarkdown.pl myfile.html F- On Apr 20, 2008, at 10:40 AM, John MacFarlane wrote: Pandoc concatenates input from all files specified on the command line. So you can just do: pandoc myfile.txt refs.txt myfile.html Seems to me that this would be a reasonable default behavior for Markdown.pl as well, but it doesn't seem to work that way now. John -- Fletcher T. Penney [EMAIL PROTECTED] If God dropped acid, would he see people? - Steven Wright smime.p7s Description: S/MIME cryptographic signature ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss
Re: Feature Request External label resolution
Fletcher T. Penney wrote: You could do something like: cat myfile.txt refs.txt | MultiMarkdown.pl myfile.html F- On Apr 20, 2008, at 10:40 AM, John MacFarlane wrote: Pandoc concatenates input from all files specified on the command line. So you can just do: pandoc myfile.txt refs.txt myfile.html Seems to me that this would be a reasonable default behavior for Markdown.pl as well, but it doesn't seem to work that way now. John ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss I've had several people who have suggested this as a valid solution. It makes sense if you have a few dozen links. And if I was sufficiently clever, I could break the site down so that references were in a bunch of refs.txt files, and no refs.txt file would have mroe than a few dozen links. However I don't know how to partition my site in such a way. If refs.txt has 2000 links in it, and every file has to parse the entire refs file, it takes a long time. As the site grows, processing time will grow quadratically. (If I double the number of files, it will also double the number of links. So a site that is twice as big will have also have twice as many links. At present I have a small site with 117 pages and 183 links. Given that In a year I figure the link count will be over a thousand. At present I have one file that has a 1000 line table (including all the tags on separate lines) When TemplateToolkit / markdown hit this file there is a 10 - 15 second pause. Since TT is doing it as an INSERT, not as an INCLUDE, TT isn't even looking at the file, so I think it's Markdown scanning this file looking for tags that is causing the delay. If a thousand line file with no partial matches is slowing down Markdown this much, I would expect that a file with 997 non-matching label/url lines and 3 matching label/url lines would cause considerably greater delay. So perhaps I should ask a more general question: How do you deal with large numbers of links? ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss
Re: Feature Request External label resolution
On Sun, Apr 20, 2008 at 1:25 PM, Sherwood Botsford [EMAIL PROTECTED] wrote: Umm. Pointers to Markdown implementations with support for extensions? [Python-Markdown][1] has an [extension api][2]. Interestingly my [Abbreviation Extension][3] for Python-Markdown does something similar for abbreviations. Given an external file, it pulls all abbr defs and uses them in processing the source file. It wouldn't be hard at all to adapt it for link defs. What I really like about it is that the external file can be any text document (markdown or otherwise) and the limited parser will only extract the abbr defs (one per line) from it. [1]: http://www.freewisdom.org/projects/python-markdown/ [2]: http://www.freewisdom.org/projects/python-markdown/Writing_Extensions [3]: http://achinghead.com/markdown/abbr/ -- Waylan Limberg [EMAIL PROTECTED] ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss
Feature Request External label resolution
One of the things I'm coming up against. Maintaining a non-small web site with many internal links is a pain. Consider: Suppose that at one point I have site/ Images Business Home ... Later the site gets more complex, and Images has a bunch of sub directories. site/ Images header_rotate inventory_pix misc Business Home When this happens I have to change the link for every pic on every page. If I use an image in 6 places, I have to change it in 6 places. HOWEVER Suppose I cleverly used the footnote form of links. I.e: [Image alt text][LABEL] Suppose that markdown was clever enough to reference an external file (in .markdownrc of course) for the resolution of LABEL. NOW when I re-arrange the universe, I only have to change the reference in this one file, NOT in every file that references it. ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss
Re: Feature Request External label resolution
Suppose that markdown was clever enough to reference an external file (in .markdownrc of course) for the resolution of LABEL. NOW when I re-arrange the universe, I only have to change the reference in this one file, NOT in every file that references it. Good idea to tokenize URL paths and what not, but it isn't Markdown's job to transform them for you ;). You'll want to pre-process those with your own script, then do your Markdown transforms. LQ ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss
Re: Feature Request External label resolution
On 20 Apr 2008, at 00:28, Sherwood Botsford wrote: [...] Suppose that markdown was clever enough to reference an external file (in .markdownrc of course) for the resolution of LABEL. Here’s a simple shell script to convert all markdown to HTML and using a shared references file: cd ~/MySite/pages for f in *.mdown; do cat $f references|Markdown.pl ../html/${f%.mdown}.html done I use something like that myself where I also have a command to update my references list, that is, grep through the pages for undefined references and add these to the references file (where I will then need to add the URI). ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss