emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Please help with a filter
@ 2014-09-02 18:55 Rafael
  2014-09-03  2:55 ` Charles Berry
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael @ 2014-09-02 18:55 UTC (permalink / raw)
  To: Emacs-orgmode list


I want that the result of exporting to markdown the following two blocks
be identical:

#+begin_src org
  #+BEGIN_MARKDOWN
  <div class="sage">
    <script type="text/x-sage">2+3</script>
  </div>
  #+END_MARKDOWN
  
  #+BEGIN_SRC sage
    2+3
  #+END_SRC
#+end_src

I have tried the following, which seems similar to examples in the web,
and I think it should work, but it doesn't:

#+begin_src emacs-lisp
  (defun org-octopress-src-block (contents backend info)
    (when (eq backend 'md)
      (let (
  	  (lang (org-element-property :language info))
  	  (value (org-element-property :value info)))
        (message "Language is %s. Value is %s" lang value)
        (when (eq lang "sage" )
        (format
         "<div class=\"sage\">
         <script type=\"text/x-sage\">%s</script>
         </div>\n"
         value
         ))
        ))
    )
  
  (add-to-list 'org-export-filter-src-block-functions
  	     'org-octopress-src-block)
#+end_src

My debugging message says: 'Language is nil. Value is nil', so I cannot
get the name of the language from the source code. What should I do to
get the filter to work?

Thanks in advance,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Please help with a filter
  2014-09-02 18:55 Please help with a filter Rafael
@ 2014-09-03  2:55 ` Charles Berry
  2014-09-03 22:32   ` Rafael
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Berry @ 2014-09-03  2:55 UTC (permalink / raw)
  To: emacs-orgmode

Rafael <rvf0068 <at> gmail.com> writes:

> 
> 
> I want that the result of exporting to markdown the following two blocks
> be identical:

Rafael,

You probably want a derived backend taking 'md as the parent. 

You want to tool up a src-block transcoder.

Look at org-html-src-block (which is what markdown uses) and create
org-md-sage-src-block (say) based on that.

The :language property in `info' - the communication channel - is a human 
language not a computer language. Confusingly, babel has an `info'
variable that has different contents.

Filters might be made to work, but it seems like more work than a
derived backend.

HTH,

Chuck

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Please help with a filter
  2014-09-03  2:55 ` Charles Berry
@ 2014-09-03 22:32   ` Rafael
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael @ 2014-09-03 22:32 UTC (permalink / raw)
  To: emacs-orgmode

Charles Berry <ccberry@ucsd.edu> writes:

> Rafael <rvf0068 <at> gmail.com> writes:
>
>> I want that the result of exporting to markdown the following two blocks
>> be identical:
>
>
> You probably want a derived backend taking 'md as the parent. 

Yes, that's what I feared.. :) I thought I could delay creating a
derived backend for later, but I guess now is the time. Thanks for your
answer, it was helpful indeed.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-03 22:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-02 18:55 Please help with a filter Rafael
2014-09-03  2:55 ` Charles Berry
2014-09-03 22:32   ` Rafael

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).