unofficial mirror of emacs-orgmode@gnu.org
 help / color / mirror / Atom feed
* Configuring text export block output
@ 2020-09-17  1:06 Tim Quelch
  2020-09-17  1:42 ` Kyle Meyer
  0 siblings, 1 reply; 3+ messages in thread
From: Tim Quelch @ 2020-09-17  1:06 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

Is there a way to configure how text is exported in ascii?

For example if I have a source block

#+begin_src python
Some code here
with multiple lines
#+end_src

With `org-ascii-export-as-ascii` the above block gives:

,----
| Some code here
| with multiple lines
`----

I don't really like this as the '|' at the start of the lines make it
annoying to copy and paste. Is there a way to configure the export to
give something surrounded by backticks?

```python
Some code here
with multiple lines
```

I've had a look into the available `org-ascii-*` customise variables and
I couldn't see anything which looked to give this functionality.
Preferably I'd love a way if I could configure this locally and
programatically, as in some contexts I might still want the "prettier"
output of the default, but in other contexts I might want the more
"practical" output of backticks.

Side question: Perhaps what I am wanting can be achieved with markdown
export, however it seems that the default markdown exporter exports code
indented. This has the same problem of being frustrating to copy-paste.
Is there a way to configure the md exporter to use fenced code blocks?

Thanks,

Tim Quelch


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

* Re: Configuring text export block output
  2020-09-17  1:06 Configuring text export block output Tim Quelch
@ 2020-09-17  1:42 ` Kyle Meyer
  2020-09-17  2:17   ` Tim Quelch
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle Meyer @ 2020-09-17  1:42 UTC (permalink / raw)
  To: Tim Quelch; +Cc: emacs-orgmode

Tim Quelch writes:

> For example if I have a source block
>
> #+begin_src python
> Some code here
> with multiple lines
> #+end_src
>
> With `org-ascii-export-as-ascii` the above block gives:
>
> ,----
> | Some code here
> | with multiple lines
> `----
>
> I don't really like this as the '|' at the start of the lines make it
> annoying to copy and paste. Is there a way to configure the export to
> give something surrounded by backticks?
>
> ```python
> Some code here
> with multiple lines
> ```
>
> I've had a look into the available `org-ascii-*` customise variables and
> I couldn't see anything which looked to give this functionality.

I don't think ox-ascii has an option to control that, but you could get
the behavior you're after by creating a derived backend.  In fact, the
section of the manual that covers derived backends provides an example
of extending the ox-ascii backend to tweak the rendering of the source
blocks.

    (info "(org)Advanced Export Configuration")

You'd only need to modify that slightly, rewriting the
my-ascii-src-block function to do what you want.  Something like

    (defun my-ascii-src-block (src-block contents info)
      (concat "```" (org-element-property :language src-block) "\n"
              (org-element-normalize-string
               (org-export-format-code-default src-block info))
              "```"))


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

* Re: Configuring text export block output
  2020-09-17  1:42 ` Kyle Meyer
@ 2020-09-17  2:17   ` Tim Quelch
  0 siblings, 0 replies; 3+ messages in thread
From: Tim Quelch @ 2020-09-17  2:17 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode


> I don't think ox-ascii has an option to control that, but you could get
> the behavior you're after by creating a derived backend.  In fact, the
> section of the manual that covers derived backends provides an example
> of extending the ox-ascii backend to tweak the rendering of the source
> blocks.

Thank you that is exactly what I was looking for. I must have missed that
example when I was looking through the docs.

Thanks,

Tim Quelch



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

end of thread, other threads:[~2020-09-17  2:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17  1:06 Configuring text export block output Tim Quelch
2020-09-17  1:42 ` Kyle Meyer
2020-09-17  2:17   ` Tim Quelch

unofficial mirror of emacs-orgmode@gnu.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/orgmode/0 orgmode/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 orgmode orgmode/ https://yhetil.org/orgmode \
		emacs-orgmode@gnu.org
	public-inbox-index orgmode

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git