Re: [O] non-standard link errors

2016-03-02 Thread Simon Thum

Hi,

after some testing I see my assumption that without export function no 
links are generated was wrong. All fine, and thanks for your 
tirelessness in explaining it so even I get it ;)


Cheers,

Simon

On 03/02/2016 10:28 AM, Nicolas Goaziou wrote:

Hello,

Simon Thum  writes:


this reminds me of my issue with tel: links. I also would have
preferred to have them exported "pass-through", but AFAICT this
requires me to come up with a trival function for every possible
backend: those I know, those I don't, and those that may not exist
yet.

I cannot switch to the raw: solution (due to vcard export). I'm not
currently experiencing problems, but I would like to suggest that
maybe such a trival default handler could be added to the backends as
some well-known property to be available to those who set the broken
link handler to e.g. 'fallback. The onus would be on the user to do
this, since correctness of output may suffer. Of course, basic
sanitation should still be done in such a handler, but preferably no
spectacular failure*.


As I explained, there is already a default handler in every major
back-end.

However, Org needs to tell links with a type from the others (internal
links). This is what `org-add-link-type' is for. This has nothing to do
with export.

To put it differently, when Org encounters a foo:bar link, there are two
options. Either "foo" is a registered link type, or not. If the former,
Org tries to use whatever export function was provided, or fall-backs to
the default handler. In the latter, Org considers it to be an internal
link. Since there is probably no #+NAME: foo:bar, <>
or * foo:bar in the document, the export process returns an error, by
default.


Regards,





Re: [O] non-standard link errors

2016-03-02 Thread Nicolas Goaziou
Hello,

Simon Thum  writes:

> this reminds me of my issue with tel: links. I also would have
> preferred to have them exported "pass-through", but AFAICT this
> requires me to come up with a trival function for every possible
> backend: those I know, those I don't, and those that may not exist
> yet.
>
> I cannot switch to the raw: solution (due to vcard export). I'm not
> currently experiencing problems, but I would like to suggest that
> maybe such a trival default handler could be added to the backends as
> some well-known property to be available to those who set the broken
> link handler to e.g. 'fallback. The onus would be on the user to do
> this, since correctness of output may suffer. Of course, basic
> sanitation should still be done in such a handler, but preferably no
> spectacular failure*.

As I explained, there is already a default handler in every major
back-end.

However, Org needs to tell links with a type from the others (internal
links). This is what `org-add-link-type' is for. This has nothing to do
with export.

To put it differently, when Org encounters a foo:bar link, there are two
options. Either "foo" is a registered link type, or not. If the former,
Org tries to use whatever export function was provided, or fall-backs to
the default handler. In the latter, Org considers it to be an internal
link. Since there is probably no #+NAME: foo:bar, <>
or * foo:bar in the document, the export process returns an error, by
default.


Regards,

-- 
Nicolas Goaziou



Re: [O] non-standard link errors

2016-03-02 Thread Simon Thum

Hi,

this reminds me of my issue with tel: links. I also would have preferred 
to have them exported "pass-through", but AFAICT this requires me to 
come up with a trival function for every possible backend: those I know, 
those I don't, and those that may not exist yet.


I cannot switch to the raw: solution (due to vcard export). I'm not 
currently experiencing problems, but I would like to suggest that maybe 
such a trival default handler could be added to the backends as some 
well-known property to be available to those who set the broken link 
handler to e.g. 'fallback. The onus would be on the user to do this, 
since correctness of output may suffer. Of course, basic sanitation 
should still be done in such a handler, but preferably no spectacular 
failure*.


Cheers,

Simon

(*) Because I sync using org exporter, I tend to suffer from those. And 
yes, I'd rather have wrong output I can diagnose than nothing.


On 02/29/2016 07:10 PM, Nicolas Goaziou wrote:

Hello,

Skip Collins  writes:


I have come up with a better solution than globally passing "broken"
links. I defined a new "raw" link type. So now if I want to put a
non-standard link in my export, I can do something like:
Here is a [[raw:foo:/\bar, baz][bad link]].
which is exported in html as:
Here is a bad link.

Now I can have non-standard links included in the output without
disabling link checking for all standard link types. This is how it is
defined in my .emacs:
(org-add-link-type "raw" 'org-raw-follow 'org-raw-export)
(defun org-raw-follow (path))
(defun org-raw-export (path desc format)
   "Export a raw link.
See `org-add-link-type' for details about PATH, DESC and FORMAT."
   (cond
((eq format 'html) (format "%s" path desc))
((eq format 'latex) (format "\\href{%s}{%s}" path desc))
((eq format 'ascii) (format "%s (%s)" desc path))
(t path)))

Perhaps this could be included in the standard Org distribution as a
fallback option for exporting non-standard link types. Emacs/Org does
nothing with the link. The user is responsible for ensuring the output
is correct.


This is already the default behavior for custom types. You don't even
need to use `org-raw-export' or `org-raw-open'. All is needed, is

  (org-add-link-type "raw")

Org requires it so it can tell if the link is an internal link or not.
However, I don't think we need to introduce a particular link type for
that. Users can define whatever they want.


Regards,





Re: [O] non-standard link errors

2016-02-29 Thread Nicolas Goaziou
Hello,

Skip Collins  writes:

> I have come up with a better solution than globally passing "broken"
> links. I defined a new "raw" link type. So now if I want to put a
> non-standard link in my export, I can do something like:
> Here is a [[raw:foo:/\bar, baz][bad link]].
> which is exported in html as:
> Here is a bad link.
>
> Now I can have non-standard links included in the output without
> disabling link checking for all standard link types. This is how it is
> defined in my .emacs:
> (org-add-link-type "raw" 'org-raw-follow 'org-raw-export)
> (defun org-raw-follow (path))
> (defun org-raw-export (path desc format)
>   "Export a raw link.
> See `org-add-link-type' for details about PATH, DESC and FORMAT."
>   (cond
>((eq format 'html) (format "%s" path desc))
>((eq format 'latex) (format "\\href{%s}{%s}" path desc))
>((eq format 'ascii) (format "%s (%s)" desc path))
>(t path)))
>
> Perhaps this could be included in the standard Org distribution as a
> fallback option for exporting non-standard link types. Emacs/Org does
> nothing with the link. The user is responsible for ensuring the output
> is correct.

This is already the default behavior for custom types. You don't even
need to use `org-raw-export' or `org-raw-open'. All is needed, is

 (org-add-link-type "raw")

Org requires it so it can tell if the link is an internal link or not.
However, I don't think we need to introduce a particular link type for
that. Users can define whatever they want.


Regards,

-- 
Nicolas Goaziou



Re: [O] non-standard link errors

2016-02-28 Thread Skip Collins
Nicolas Goaziou  wrote:
> Not that I'm against the idea, but wouldn't it be a poor way to properly
> fix the issue, i.e., add new link types?

I have come up with a better solution than globally passing "broken"
links. I defined a new "raw" link type. So now if I want to put a
non-standard link in my export, I can do something like:
Here is a [[raw:foo:/\bar, baz][bad link]].
which is exported in html as:
Here is a bad link.

Now I can have non-standard links included in the output without
disabling link checking for all standard link types. This is how it is
defined in my .emacs:
(org-add-link-type "raw" 'org-raw-follow 'org-raw-export)
(defun org-raw-follow (path))
(defun org-raw-export (path desc format)
  "Export a raw link.
See `org-add-link-type' for details about PATH, DESC and FORMAT."
  (cond
   ((eq format 'html) (format "%s" path desc))
   ((eq format 'latex) (format "\\href{%s}{%s}" path desc))
   ((eq format 'ascii) (format "%s (%s)" desc path))
   (t path)))

Perhaps this could be included in the standard Org distribution as a
fallback option for exporting non-standard link types. Emacs/Org does
nothing with the link. The user is responsible for ensuring the output
is correct.



Re: [O] non-standard link errors

2016-02-28 Thread Nicolas Goaziou
Hello,

Skip Collins  writes:

> I added this line to the top of my org file:
> #+OPTIONS: broken-links:t
>
> But that eliminates both the link and its description from the export.
> Changing it from 't' to 'mark' puts a BROKEN LINK message in the
> output. I suggest adding a new option 'pass' that would simply pass
> "broken" links verbatim into the output.

Not that I'm against the idea, but wouldn't it be a poor way to properly
fix the issue, i.e., add new link types?

Regards,

-- 
Nicolas Goaziou



Re: [O] non-standard link errors

2016-02-27 Thread Skip Collins
Nicolas Goaziou  wrote:
> Skip Collins  writes:
> > Org throws an error when I export html with a link type that it does
> > not know about. I would like it to simply add the link to the exported
> > document without checking its validity. For example, I have a link
> > that, when tapped on an iPhone, will open a particular app. I would
> > like the html to look something like:
> > Connect using FaceTime
> >
> > The link works on an iPhone. But Org won't generate the html. Other
> > apps uses x-callback-url links formatted like this:
> > x-appname://x-callback-url/import?=Open%20Mail.app.
> >
> > These also do not work. Short of adding every type I might want to use
> > with org-add-link-type, is it possible to disable the export error and
> > just pass links through as written?
>
> It is possible in development version, where a variable controlling how
> link errors should be handled was introduced.

I added this line to the top of my org file:
#+OPTIONS: broken-links:t

But that eliminates both the link and its description from the export.
Changing it from 't' to 'mark' puts a BROKEN LINK message in the
output. I suggest adding a new option 'pass' that would simply pass
"broken" links verbatim into the output.



Re: [O] non-standard link errors

2016-02-26 Thread Nicolas Goaziou
Hello,

Skip Collins  writes:

> Org throws an error when I export html with a link type that it does
> not know about. I would like it to simply add the link to the exported
> document without checking its validity. For example, I have a link
> that, when tapped on an iPhone, will open a particular app. I would
> like the html to look something like:
> Connect using FaceTime
>
> The link works on an iPhone. But Org won't generate the html. Other
> apps uses x-callback-url links formatted like this:
> x-appname://x-callback-url/import?=Open%20Mail.app.
>
> These also do not work. Short of adding every type I might want to use
> with org-add-link-type, is it possible to disable the export error and
> just pass links through as written?

It is possible in development version, where a variable controlling how
link errors should be handled was introduced.

Regards,

-- 
Nicolas Goaziou