From: "François Pinard" <pinard@iro.umontreal.ca>
To: emacs-orgmode@gnu.org
Subject: Publishing Org to Org?
Date: Sun, 03 Jun 2012 21:58:45 -0400 [thread overview]
Message-ID: <86ipf7ald6.fsf@mercure.progiciels-bpi.ca> (raw)
Hi, Org people!
GitHub renders a README.md file right at the end of the project page,
using bigger fonts for titles, producing clickable links, and such
things. As I did not feel like maintaining the same information both in
Org and Markdown format, I used the Org -> [org-publish] -> HTML ->
[Pandoc] -> Md route. I do not make the Org file directly available, as
there are not wholly meant for publication. It works well because the
non-exportable and other private bits are stripped before the HTML is
produced. However, Org tables do not nicely survive this route.
Now, GitHub allows for README.org files, and renders them. The
rendering job is far from perfect, but still, it might be acceptable if
one limits himself to those Org features which GitHub processes
correctly. One good thing is that we get better tables this way. I may
not directly publish the original Org file because of its private parts.
So I quickly wrote a small Org copier, tied to my own habits and not
trying to be generic. I provide it below, in case someone is curious.
My feeling is that ideally, Org should itself provide a standard Org
exporter, as generic as it should be. One tiny problem, among all
others, is to decide which file extension to use for the result, as .org
is already used for the input file. Just a thought :-).
François
--8<---------------cut here---------------start------------->8---
#!/usr/bin/env python3
"""\
Trim the private parts of an Org file.
Usage: trim-org [ORG_FILE]
Results go to standard output.
"""
import re, sys
header_prefix_regexp = ('^(\\*+) '
'(\\[#[ABC]\\] )?'
'(TODO |NEXT |DONE |WAIT )?'
'(\\*)?')
# 1 = stars, 2 = priority, 3 = keyword, 4 = once
# 5 = text followed by spaces, 6 = tags
header_regexp = header_prefix_regexp + '(.*?)((:[a-z]+)+:)?$'
class Main:
def main(self, *arguments):
import getopt
options, arguments = getopt.getopt(arguments, '')
for option, value in options:
pass
if arguments:
for argument in arguments:
self.trim_file(open(argument), sys.stdout.write)
else:
self.trim_file(sys.stdin, sys.stdout.write)
def trim_file(self, lines, write):
noexport = None
for line in lines:
match = re.match(header_regexp, line)
if match is not None:
level = len(match.group(1))
if noexport is not None and level <= noexport:
noexport = None
tags = match.group(6)
if noexport is None and tags and ':noexport:' in tags:
noexport = level
if noexport is None:
if (not line.startswith('#')
or line.startswith('#+')
or line.startswith('# <<')):
write(line)
run = Main()
main = run.main
if __name__ == '__main__':
main(*sys.argv[1:])
--8<---------------cut here---------------end--------------->8---
next reply other threads:[~2012-06-04 1:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-04 1:58 François Pinard [this message]
2012-06-04 9:47 ` Publishing Org to Org? suvayu ali
2012-06-04 15:59 ` François Pinard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86ipf7ald6.fsf@mercure.progiciels-bpi.ca \
--to=pinard@iro.umontreal.ca \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).