help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Org to Markdown programmatically


From: Jean Louis
Subject: Re: Org to Markdown programmatically
Date: Sat, 22 May 2021 11:26:37 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* Colin Baxter <m43cap@yandex.com> [2021-05-04 13:24]:
> >>>>> Emanuel Berg via Users list for the GNU Emacs text editor 
> >>>>> <help-gnu-emacs@gnu.org> writes:
> 
>     > Jean Louis wrote:
>     >> As I am editing database strings, not files, I have to export
>     >> programmatically Org blobs into HTML.
> 
>     > See if pandoc can do this...
> 
> It can:
> 
> pandoc -o file.md file.org <RET>

Thanks. That would maybe export .org to Markdown. I have never tried
it and don't have intention as pandoc is not Emacs and cannot possibly
support full Org mode.

Database has its tables, that have columns with values. I am editing
column values with Emacs, but I could choose that Emacs invoke
external editor for editing. 

When inside of Emacs, it is faster to convert .Org to to Markdown then
to invoke external pandoc.

But you know Org, it can be so complicated... pandoc handles only
simple things. And is huge software, requires Haskell, which is about
non-reproducible.

I use pandoc for highlighting in some Markdown outputs.

Here is one handy function that may help user to capture the
selected/marked region in a browser and convert it to Markdown file. 

(defun clipboard-to-markdown-file ()
  "This function helps to capture HTML from web pages into files
in Markdown format. You would need to mark the parts of the HTML
page within your browser such as Iceweasel or IceCat. Then you
run this function in Emacs Lisp. It uses `pandoc' and `xclip'
shell commands to write Markdown file. Finally it opens file for
editing."
  (interactive)
  (let* ((markdown-dir "/home/data1/protected/Documents/HTML-Markdown/")
         (filename (concat markdown-dir (rcd-timestamp) ".md"))
         (clipboard (xclip-primary-selection-html))
         (markdown (command-stream "pandoc" clipboard "-r" "html" "-w" 
"commonmark")))
    (string-to-file-force markdown filename)
    (find-file filename)))



-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]