* Need help exporting subtrees to html @ 2009-12-27 16:34 Juan Reyero 2009-12-27 18:35 ` Carsten Dominik 0 siblings, 1 reply; 10+ messages in thread From: Juan Reyero @ 2009-12-27 16:34 UTC (permalink / raw) To: org-mode Mailing List Greetings, I have written a function to export org-mode subtrees as jekyll posts, http://juanreyero.com/open/org-jekyll/ The idea is that any entry in an org-publish project that has a :blog: keyword and an :on: property with a timestamp should be exported to a _posts directory with the year-month-day-title.html that jekyll expects, with the properties as front-matter. I was very happy with it, until I realized that the levels of the headers in the exported file (h2, h3, etc) depend on the indentation of the subtree in the outline. I wanted to be able to add a :blog: subtree anywhere in my project's files, and get it always exported the same, regardless of where in the outline it is. Is there any reasonably simple way to overcome this problem? I am using: (org-narrow-to-subtree) (setq html (org-export-as-html nil nil nil 'string t nil)) to do the exporting (all the code is in github, http://github.com/juanre/org-jekyll). In summary, what I need is an org-export-as-html that treats the least indented outline as a 0-indentation. Best, Juan -- http://juanreyero.com/ http://unarueda.com ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Need help exporting subtrees to html 2009-12-27 16:34 Need help exporting subtrees to html Juan Reyero @ 2009-12-27 18:35 ` Carsten Dominik 2009-12-27 19:31 ` Juan Reyero 0 siblings, 1 reply; 10+ messages in thread From: Carsten Dominik @ 2009-12-27 18:35 UTC (permalink / raw) To: Juan Reyero; +Cc: org-mode Mailing List On Dec 27, 2009, at 5:34 PM, Juan Reyero wrote: > Greetings, > > I have written a function to export org-mode subtrees as jekyll posts, > http://juanreyero.com/open/org-jekyll/ The idea is that any entry in > an org-publish project that has a :blog: keyword and an :on: property > with a timestamp should be exported to a _posts directory with the > year-month-day-title.html that jekyll expects, with the properties as > front-matter. > > I was very happy with it, until I realized that the levels of the > headers in the exported file (h2, h3, etc) depend on the indentation > of the subtree in the outline. I wanted to be able to add a :blog: > subtree anywhere in my project's files, and get it always exported the > same, regardless of where in the outline it is. > > Is there any reasonably simple way to overcome this problem? I am > using: > > (org-narrow-to-subtree) > (setq html (org-export-as-html nil nil nil 'string t nil)) Hi Juan, Try this: (outline-mark-subtree) (setq html (org-export-as-html nil nil nil 'string t nil)) HTH - Carsten ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Need help exporting subtrees to html 2009-12-27 18:35 ` Carsten Dominik @ 2009-12-27 19:31 ` Juan Reyero 2009-12-31 8:15 ` Carsten Dominik 0 siblings, 1 reply; 10+ messages in thread From: Juan Reyero @ 2009-12-27 19:31 UTC (permalink / raw) To: Carsten Dominik, org-mode Mailing List Hi Carsten, On Sun, Dec 27, 2009 at 7:35 PM, Carsten Dominik <carsten.dominik@gmail.com> wrote: > On Dec 27, 2009, at 5:34 PM, Juan Reyero wrote: >> I have written a function to export org-mode subtrees as jekyll posts, >> http://juanreyero.com/open/org-jekyll/ The idea is that any entry in >> an org-publish project that has a :blog: keyword and an :on: property >> with a timestamp should be exported to a _posts directory with the >> year-month-day-title.html that jekyll expects, with the properties as >> front-matter. >> >> I was very happy with it, until I realized that the levels of the >> headers in the exported file (h2, h3, etc) depend on the indentation >> of the subtree in the outline. I wanted to be able to add a :blog: >> subtree anywhere in my project's files, and get it always exported the >> same, regardless of where in the outline it is. >> >> Is there any reasonably simple way to overcome this problem? I am using: >> >> (org-narrow-to-subtree) >> (setq html (org-export-as-html nil nil nil 'string t nil)) > > Hi Juan, > > Try this: > > (outline-mark-subtree) > (setq html (org-export-as-html nil nil nil 'string t nil)) Thanks for your answer. I've tried it, but now it exports the whole buffer, as if (outline-mark-subtree) didn't understand which subtree I am looking at. I am doing this from within an (org-map-entries). If I first narrow and then mark it doesn't work either: it complains of "Before first headline at position...". I have updated the tests at http://github.com/juanre/org-jekyll to reflect the problem. Best, Juan -- http://juanreyero.com/ http://unarueda.com ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Need help exporting subtrees to html 2009-12-27 19:31 ` Juan Reyero @ 2009-12-31 8:15 ` Carsten Dominik 2009-12-31 13:50 ` Juan Reyero 0 siblings, 1 reply; 10+ messages in thread From: Carsten Dominik @ 2009-12-31 8:15 UTC (permalink / raw) To: Juan Reyero; +Cc: org-mode Mailing List On Dec 27, 2009, at 8:31 PM, Juan Reyero wrote: > Hi Carsten, > > On Sun, Dec 27, 2009 at 7:35 PM, Carsten Dominik > <carsten.dominik@gmail.com> wrote: >> On Dec 27, 2009, at 5:34 PM, Juan Reyero wrote: >>> I have written a function to export org-mode subtrees as jekyll >>> posts, >>> http://juanreyero.com/open/org-jekyll/ The idea is that any entry >>> in >>> an org-publish project that has a :blog: keyword and an :on: >>> property >>> with a timestamp should be exported to a _posts directory with the >>> year-month-day-title.html that jekyll expects, with the properties >>> as >>> front-matter. >>> >>> I was very happy with it, until I realized that the levels of the >>> headers in the exported file (h2, h3, etc) depend on the indentation >>> of the subtree in the outline. I wanted to be able to add a :blog: >>> subtree anywhere in my project's files, and get it always exported >>> the >>> same, regardless of where in the outline it is. >>> >>> Is there any reasonably simple way to overcome this problem? I am >>> using: >>> >>> (org-narrow-to-subtree) >>> (setq html (org-export-as-html nil nil nil 'string t nil)) >> >> Hi Juan, >> >> Try this: >> >> (outline-mark-subtree) >> (setq html (org-export-as-html nil nil nil 'string t nil)) > > Thanks for your answer. I've tried it, but now it exports the whole > buffer, as if (outline-mark-subtree) didn't understand which subtree I > am looking at. I am doing this from within an (org-map-entries). If > I first narrow and then mark it doesn't work either: it complains of > "Before first headline at position...". You are right, this does not work as I had hoped. What needs to be done is that the tree must be selected, and the region needs to be *active* when the export command is called. I am not quite sure right now how to do this in the middle of a Lisp program.... - Carsten > > I have updated the tests at http://github.com/juanre/org-jekyll to > reflect the problem. > > Best, > > Juan > -- > http://juanreyero.com/ > http://unarueda.com - Carsten ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Need help exporting subtrees to html 2009-12-31 8:15 ` Carsten Dominik @ 2009-12-31 13:50 ` Juan Reyero 2009-12-31 17:15 ` Eric Schulte 0 siblings, 1 reply; 10+ messages in thread From: Juan Reyero @ 2009-12-31 13:50 UTC (permalink / raw) To: Carsten Dominik, org-mode Mailing List On Thu, Dec 31, 2009 at 9:15 AM, Carsten Dominik <carsten.dominik@gmail.com> wrote: > On Dec 27, 2009, at 8:31 PM, Juan Reyero wrote: >> On Sun, Dec 27, 2009 at 7:35 PM, Carsten Dominik >> <carsten.dominik@gmail.com> wrote: >>> On Dec 27, 2009, at 5:34 PM, Juan Reyero wrote: >>>> I have written a function to export org-mode subtrees as jekyll posts, >>>> http://juanreyero.com/open/org-jekyll/ The idea is that any entry in >>>> an org-publish project that has a :blog: keyword and an :on: property >>>> with a timestamp should be exported to a _posts directory with the >>>> year-month-day-title.html that jekyll expects, with the properties as >>>> front-matter. >>>> >>>> I was very happy with it, until I realized that the levels of the >>>> headers in the exported file (h2, h3, etc) depend on the indentation >>>> of the subtree in the outline. I wanted to be able to add a :blog: >>>> subtree anywhere in my project's files, and get it always exported the >>>> same, regardless of where in the outline it is. >>>> >>>> Is there any reasonably simple way to overcome this problem? I am >>>> using: >>>> >>>> (org-narrow-to-subtree) >>>> (setq html (org-export-as-html nil nil nil 'string t nil)) >>> >>> Hi Juan, >>> >>> Try this: >>> >>> (outline-mark-subtree) >>> (setq html (org-export-as-html nil nil nil 'string t nil)) >> >> Thanks for your answer. I've tried it, but now it exports the whole >> buffer, as if (outline-mark-subtree) didn't understand which subtree I >> am looking at. I am doing this from within an (org-map-entries). If >> I first narrow and then mark it doesn't work either: it complains of >> "Before first headline at position...". > > You are right, this does not work as I had hoped. What needs to be > done is that the tree must be selected, and the region needs to be *active* > when the export command is called. I am not quite sure right now > how to do this in the middle of a Lisp program.... Looks like it is not going to be a small investment. For the time being I'll stick to writing blog posts as first-level entries, and I'll try to figure it out when I find some more time. Thank you very much for your answers. Cheers, Juan >> I have updated the tests at http://github.com/juanre/org-jekyll to >> reflect the problem. -- http://juanreyero.com/ http://unarueda.com ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Need help exporting subtrees to html 2009-12-31 13:50 ` Juan Reyero @ 2009-12-31 17:15 ` Eric Schulte 2009-12-31 17:17 ` Eric Schulte 2009-12-31 18:02 ` Juan Reyero 0 siblings, 2 replies; 10+ messages in thread From: Eric Schulte @ 2009-12-31 17:15 UTC (permalink / raw) To: Juan Reyero; +Cc: org-mode Mailing List, Carsten Dominik Juan Reyero <joanmg@gmail.com> writes: > On Thu, Dec 31, 2009 at 9:15 AM, Carsten Dominik > <carsten.dominik@gmail.com> wrote: >> On Dec 27, 2009, at 8:31 PM, Juan Reyero wrote: >>> On Sun, Dec 27, 2009 at 7:35 PM, Carsten Dominik >>> <carsten.dominik@gmail.com> wrote: >>>> On Dec 27, 2009, at 5:34 PM, Juan Reyero wrote: >>>>> I have written a function to export org-mode subtrees as jekyll posts, >>>>> http://juanreyero.com/open/org-jekyll/ The idea is that any entry in >>>>> an org-publish project that has a :blog: keyword and an :on: property >>>>> with a timestamp should be exported to a _posts directory with the >>>>> year-month-day-title.html that jekyll expects, with the properties as >>>>> front-matter. [...] > Looks like it is not going to be a small investment. For the time > being I'll stick to writing blog posts as first-level entries, and > I'll try to figure it out when I find some more time. Thank you very > much for your answers. > Hi, If it helps, I've been doing something similar to support publishing updates on the org-babel development -- using the code shown here [1] under the "Development Updates" section. This generates a files in _posts for each subtree of of the "tasks" and "bugs" sections which have a time-stamp in their properties. It should be fairly straightforward to adapt this code to export all properties as YAML frontmatter. Best -- Eric Footnotes: [1] http://eschulte.github.com/babel-dev/publish.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Need help exporting subtrees to html 2009-12-31 17:15 ` Eric Schulte @ 2009-12-31 17:17 ` Eric Schulte 2009-12-31 18:02 ` Juan Reyero 1 sibling, 0 replies; 10+ messages in thread From: Eric Schulte @ 2009-12-31 17:17 UTC (permalink / raw) To: Juan Reyero; +Cc: org-mode Mailing List, Carsten Dominik Also, please share your results with Worg - http://orgmode.org/worg/org-tutorials/org-jekyll.php - http://orgmode.org/worg/org-blog-wiki.php Thanks -- Eric "Eric Schulte" <schulte.eric@gmail.com> writes: > Juan Reyero <joanmg@gmail.com> writes: > >> On Thu, Dec 31, 2009 at 9:15 AM, Carsten Dominik >> <carsten.dominik@gmail.com> wrote: >>> On Dec 27, 2009, at 8:31 PM, Juan Reyero wrote: >>>> On Sun, Dec 27, 2009 at 7:35 PM, Carsten Dominik >>>> <carsten.dominik@gmail.com> wrote: >>>>> On Dec 27, 2009, at 5:34 PM, Juan Reyero wrote: >>>>>> I have written a function to export org-mode subtrees as jekyll posts, >>>>>> http://juanreyero.com/open/org-jekyll/ The idea is that any entry in >>>>>> an org-publish project that has a :blog: keyword and an :on: property >>>>>> with a timestamp should be exported to a _posts directory with the >>>>>> year-month-day-title.html that jekyll expects, with the properties as >>>>>> front-matter. > [...] >> Looks like it is not going to be a small investment. For the time >> being I'll stick to writing blog posts as first-level entries, and >> I'll try to figure it out when I find some more time. Thank you very >> much for your answers. >> > > Hi, > > If it helps, I've been doing something similar to support publishing > updates on the org-babel development -- using the code shown here [1] > under the "Development Updates" section. This generates a files in > _posts for each subtree of of the "tasks" and "bugs" sections which have > a time-stamp in their properties. It should be fairly straightforward > to adapt this code to export all properties as YAML frontmatter. > > Best -- Eric > > Footnotes: > [1] http://eschulte.github.com/babel-dev/publish.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Need help exporting subtrees to html 2009-12-31 17:15 ` Eric Schulte 2009-12-31 17:17 ` Eric Schulte @ 2009-12-31 18:02 ` Juan Reyero 2009-12-31 19:51 ` Eric Schulte 1 sibling, 1 reply; 10+ messages in thread From: Juan Reyero @ 2009-12-31 18:02 UTC (permalink / raw) To: Eric Schulte, Carsten Dominik, org-mode Mailing List On Thu, Dec 31, 2009 at 6:15 PM, Eric Schulte <schulte.eric@gmail.com> wrote: > Juan Reyero <joanmg@gmail.com> writes: > >> On Thu, Dec 31, 2009 at 9:15 AM, Carsten Dominik >> <carsten.dominik@gmail.com> wrote: >>> On Dec 27, 2009, at 8:31 PM, Juan Reyero wrote: >>>> On Sun, Dec 27, 2009 at 7:35 PM, Carsten Dominik >>>> <carsten.dominik@gmail.com> wrote: >>>>> On Dec 27, 2009, at 5:34 PM, Juan Reyero wrote: >>>>>> I have written a function to export org-mode subtrees as jekyll posts, >>>>>> http://juanreyero.com/open/org-jekyll/ The idea is that any entry in >>>>>> an org-publish project that has a :blog: keyword and an :on: property >>>>>> with a timestamp should be exported to a _posts directory with the >>>>>> year-month-day-title.html that jekyll expects, with the properties as >>>>>> front-matter. > If it helps, I've been doing something similar to support publishing > updates on the org-babel development -- using the code shown here [1] > under the "Development Updates" section. This generates a files in > _posts for each subtree of of the "tasks" and "bugs" sections which have > a time-stamp in their properties. It should be fairly straightforward > to adapt this code to export all properties as YAML frontmatter. It is exactly what I did :-). I found your code here [1], and adapted it so that it would use files in an org-publish project and would export properties. So thank you very much for making it available. It does, however, have the same problem I find: the header level with which the piece is exported (h1, h2, etc) depends on the outline level on which the item you export happened to be. I was hoping to export the chunks independently of where they were written. I will share it with Worg as soon as I manage to make it work. Best, Juan Footnotes: [1] http://orgmode.org/worg/org-tutorials/org-jekyll.php (end of document). > > Best -- Eric > > Footnotes: > [1] http://eschulte.github.com/babel-dev/publish.html > > -- http://juanreyero.com/ http://unarueda.com ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Need help exporting subtrees to html 2009-12-31 18:02 ` Juan Reyero @ 2009-12-31 19:51 ` Eric Schulte 2010-01-01 13:33 ` Juan Reyero 0 siblings, 1 reply; 10+ messages in thread From: Eric Schulte @ 2009-12-31 19:51 UTC (permalink / raw) To: Juan Reyero; +Cc: org-mode Mailing List, Carsten Dominik Juan Reyero <joanmg@gmail.com> writes: > On Thu, Dec 31, 2009 at 6:15 PM, Eric Schulte <schulte.eric@gmail.com> wrote: >> Juan Reyero <joanmg@gmail.com> writes: >> >>> On Thu, Dec 31, 2009 at 9:15 AM, Carsten Dominik >>> <carsten.dominik@gmail.com> wrote: >>>> On Dec 27, 2009, at 8:31 PM, Juan Reyero wrote: >>>>> On Sun, Dec 27, 2009 at 7:35 PM, Carsten Dominik >>>>> <carsten.dominik@gmail.com> wrote: >>>>>> On Dec 27, 2009, at 5:34 PM, Juan Reyero wrote: >>>>>>> I have written a function to export org-mode subtrees as jekyll posts, >>>>>>> http://juanreyero.com/open/org-jekyll/ The idea is that any entry in >>>>>>> an org-publish project that has a :blog: keyword and an :on: property >>>>>>> with a timestamp should be exported to a _posts directory with the >>>>>>> year-month-day-title.html that jekyll expects, with the properties as >>>>>>> front-matter. >> If it helps, I've been doing something similar to support publishing >> updates on the org-babel development -- using the code shown here [1] >> under the "Development Updates" section. This generates a files in >> _posts for each subtree of of the "tasks" and "bugs" sections which have >> a time-stamp in their properties. It should be fairly straightforward >> to adapt this code to export all properties as YAML frontmatter. > > It is exactly what I did :-). I found your code here [1], and adapted > it so that it would use files in an org-publish project and would > export properties. Ah, I should have read the thread more carefully :) > So thank you very much for making it available. It does, however, > have the same problem I find: the header level with which the piece is > exported (h1, h2, etc) depends on the outline level on which the item > you export happened to be. I was hoping to export the chunks > independently of where they were written. > So this turned out to be somewhat tricky. I was able to adjust my previous code so that every subtree will be promoted to a top-level heading before export by adding the following (this change can also be seen in my published code here [1]). --8<---------------cut here---------------start------------->8--- (org-narrow-to-subtree) (let ((level (- (org-outline-level) 1)) (contents (buffer-substring (point-min) (point-max)))) (dotimes (n level nil) (org-promote-subtree)) (setq html (org-export-as-html nil nil nil 'string t nil)) (set-buffer org-buffer) (delete-region (point-min) (point-max)) (insert contents) (save-buffer)) (widen) --8<---------------cut here---------------end--------------->8--- Hope this helps. Cheers -- Eric > > I will share it with Worg as soon as I manage to make it work. > > Best, > > Juan > > Footnotes: > [1] http://orgmode.org/worg/org-tutorials/org-jekyll.php (end of document). > >> >> Best -- Eric >> >> Footnotes: >> [1] http://eschulte.github.com/babel-dev/publish.html >> >> Footnotes: [1] http://eschulte.github.com/babel-dev/publish.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Need help exporting subtrees to html 2009-12-31 19:51 ` Eric Schulte @ 2010-01-01 13:33 ` Juan Reyero 0 siblings, 0 replies; 10+ messages in thread From: Juan Reyero @ 2010-01-01 13:33 UTC (permalink / raw) To: Eric Schulte; +Cc: org-mode Mailing List, Carsten Dominik On Thu, Dec 31, 2009 at 8:51 PM, Eric Schulte <schulte.eric@gmail.com> wrote: > Juan Reyero <joanmg@gmail.com> writes: > >> On Thu, Dec 31, 2009 at 6:15 PM, Eric Schulte <schulte.eric@gmail.com> wrote: >>> Juan Reyero <joanmg@gmail.com> writes: >>> >>>> On Thu, Dec 31, 2009 at 9:15 AM, Carsten Dominik >>>> <carsten.dominik@gmail.com> wrote: >>>>> On Dec 27, 2009, at 8:31 PM, Juan Reyero wrote: >>>>>> On Sun, Dec 27, 2009 at 7:35 PM, Carsten Dominik >>>>>> <carsten.dominik@gmail.com> wrote: >>>>>>> On Dec 27, 2009, at 5:34 PM, Juan Reyero wrote: >>>>>>>> I have written a function to export org-mode subtrees as jekyll posts, >>>>>>>> http://juanreyero.com/open/org-jekyll/ The idea is that any entry in >>>>>>>> an org-publish project that has a :blog: keyword and an :on: property >>>>>>>> with a timestamp should be exported to a _posts directory with the >>>>>>>> year-month-day-title.html that jekyll expects, with the properties as >>>>>>>> front-matter. >>> If it helps, I've been doing something similar to support publishing >>> updates on the org-babel development -- using the code shown here [1] >>> under the "Development Updates" section. This generates a files in >>> _posts for each subtree of of the "tasks" and "bugs" sections which have >>> a time-stamp in their properties. It should be fairly straightforward >>> to adapt this code to export all properties as YAML frontmatter. >> >> It is exactly what I did :-). I found your code here [1], and adapted >> it so that it would use files in an org-publish project and would >> export properties. > > Ah, I should have read the thread more carefully :) > >> So thank you very much for making it available. It does, however, >> have the same problem I find: the header level with which the piece is >> exported (h1, h2, etc) depends on the outline level on which the item >> you export happened to be. I was hoping to export the chunks >> independently of where they were written. >> > > So this turned out to be somewhat tricky. I was able to adjust my > previous code so that every subtree will be promoted to a top-level > heading before export by adding the following (this change can also be > seen in my published code here [1]). > > --8<---------------cut here---------------start------------->8--- > (org-narrow-to-subtree) > (let ((level (- (org-outline-level) 1)) > (contents (buffer-substring (point-min) (point-max)))) > (dotimes (n level nil) (org-promote-subtree)) > (setq html (org-export-as-html nil nil nil 'string t nil)) > (set-buffer org-buffer) > (delete-region (point-min) (point-max)) > (insert contents) > (save-buffer)) > (widen) > --8<---------------cut here---------------end--------------->8--- It works! Thank you _very_ much. I've just had to add a org-reduced-level to the org-outline-level, like (org-reduced-level (org-outline-level)). I've updated it in github and on http://juanreyero.com/open/org-jekyll/, and I'll try to add something to worg this afternoon. Best, Juan > Footnotes: > [1] http://eschulte.github.com/babel-dev/publish.html -- http://juanreyero.com/ http://unarueda.com ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-01-01 13:33 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-12-27 16:34 Need help exporting subtrees to html Juan Reyero 2009-12-27 18:35 ` Carsten Dominik 2009-12-27 19:31 ` Juan Reyero 2009-12-31 8:15 ` Carsten Dominik 2009-12-31 13:50 ` Juan Reyero 2009-12-31 17:15 ` Eric Schulte 2009-12-31 17:17 ` Eric Schulte 2009-12-31 18:02 ` Juan Reyero 2009-12-31 19:51 ` Eric Schulte 2010-01-01 13:33 ` Juan Reyero
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).