emphasize word ending in single underscore

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

emphasize word ending in single underscore

Andreas Reuleaux
Hi,

How would I do the following formatting:

some of my words deliberatly end with single underscores:
but I would the whole word to be emphasized:

Here is an example of my text:

  the expr parser parses expressions, while the expr_
  parser is its white space aware counterpart.

Now I want both: expr and expr_ to be emphasized.

die html I want is

  <em>expr<em> ... <em>expr_<em>

while I found out that I can achieve that effect with
 
  pass:[<em>expr_</em>]

this works only for the html rendering, the pdf is broken,
I guess one can use some kind of function somewhere,
that does distinguish between html and pdf rendering
(pointers? - have never used that before).

ideally I'd have something very short, like so

  _expr_ ...  em:[expr_]


that works for both html and pdf, as I write
not only about expression parsers, but also
about decls, and much more stuff in this manner.

Thanks in advance, and please bear with me:
I am relatively new to asciidoctor.

-Andreas


Reply | Threaded
Open this post in threaded view
|

Re: emphasize word ending in single underscore

mojavelinux
Administrator
Have you tried it yet? In my tests, it works out just fine.

The following AsciiDoc:

----
the _expr_ parser parses expressions, while the _expr__ parser is its white space aware counterpart.
----

produces the following HTML (abbreviated):

----
<p>the <em>expr</em> parser parses expressions, while the <em>expr_</em> parser is its white space aware counterpart.</p>
----

Btw, if you wanted to use the pass macro (just to be sure) you'd type it as:

_pass:[expr_]_

That will work in both HTML and PDF. It's best to avoid putting HTML directly in your AsciiDoc.

Cheers,

-Dan

On Thu, Aug 6, 2015 at 1:21 AM, Andreas Reuleaux [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi,

How would I do the following formatting:

some of my words deliberatly end with single underscores:
but I would the whole word to be emphasized:

Here is an example of my text:

  the expr parser parses expressions, while the expr_
  parser is its white space aware counterpart.

Now I want both: expr and expr_ to be emphasized.

die html I want is

  <em>expr<em> ... <em>expr_<em>

while I found out that I can achieve that effect with
 
  pass:[<em>expr_</em>]

this works only for the html rendering, the pdf is broken,
I guess one can use some kind of function somewhere,
that does distinguish between html and pdf rendering
(pointers? - have never used that before).

ideally I'd have something very short, like so

  _expr_ ...  em:[expr_]


that works for both html and pdf, as I write
not only about expression parsers, but also
about decls, and much more stuff in this manner.

Thanks in advance, and please bear with me:
I am relatively new to asciidoctor.

-Andreas





If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/emphasize-word-ending-in-single-underscore-tp3629.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: emphasize word ending in single underscore

Andreas Reuleaux
Well, thanks a lot, first of all.

Hm, yes, I have tried: _expr__
- worked for me sometimes, but not reliably,
ie. depending on wheter it was followed by a comma eg.

  ... expr_, ...

wheter there were other emphasis starting later on the
same line etc. - Don't have a very clear picture at
present, what circumstances exactly caused it two break,
but will give it another shot maybe.

Other variations that I tried with some kind of \ - escaping
didn't work out well either, sometimes I got something close
<em>expr<em>_  but not exactly what I wanted: the underscore within
the em (even if this distinction was barely visible).

Anyway thanks a lot, with your _pass:[expr_]_
I am now on the safe side: can use _expr__ when it works,
and otherwise resort to _pass:[expr_]_


Thanks again,
 -Andreas


"mojavelinux [via Asciidoctor :: Discussion]"
<[hidden email]> writes:

> Have you tried it yet? In my tests, it works out just fine.
>
> The following AsciiDoc:
>
> ----
> the _expr_ parser parses expressions, while the _expr__ parser is its white
> space aware counterpart.
> ----
>
> produces the following HTML (abbreviated):
>
> ----
> <p>the <em>expr</em> parser parses expressions, while the <em>expr_</em>
> parser is its white space aware counterpart.</p>
> ----
>
> Btw, if you wanted to use the pass macro (just to be sure) you'd type it as:
>
> _pass:[expr_]_
>
> That will work in both HTML and PDF. It's best to avoid putting HTML
> directly in your AsciiDoc.
>
> Cheers,
>
> -Dan
>
> On Thu, Aug 6, 2015 at 1:21 AM, Andreas Reuleaux [via Asciidoctor ::
> Discussion] <[hidden email]> wrote:
>
>> Hi,
>>
>> How would I do the following formatting:
>>
>> some of my words deliberatly end with single underscores:
>> but I would the whole word to be emphasized:
>>
>> Here is an example of my text:
>>
>>   the expr parser parses expressions, while the expr_
>>   parser is its white space aware counterpart.
>>
>> Now I want both: expr and expr_ to be emphasized.
>>
>> die html I want is
>>
>>   <em>expr<em> ... <em>expr_<em>
>>
>> while I found out that I can achieve that effect with
>>
>>   pass:[<em>expr_</em>]
>>
>> this works only for the html rendering, the pdf is broken,
>> I guess one can use some kind of function somewhere,
>> that does distinguish between html and pdf rendering
>> (pointers? - have never used that before).
>>
>> ideally I'd have something very short, like so
>>
>>   _expr_ ...  em:[expr_]
>>
>>
>> that works for both html and pdf, as I write
>> not only about expression parsers, but also
>> about decls, and much more stuff in this manner.
>>
>> Thanks in advance, and please bear with me:
>> I am relatively new to asciidoctor.
>>
>> -Andreas
>>
>>
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://discuss.asciidoctor.org/emphasize-word-ending-in-single-underscore-tp3629.html
>> To start a new topic under Asciidoctor :: Discussion, email
>> [hidden email]
>> To unsubscribe from Asciidoctor :: Discussion, click here
>> <
>> .
>> NAML
>> <
http://discuss.asciidoctor.org/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>

Reply | Threaded
Open this post in threaded view
|

Re: emphasize word ending in single underscore

jvdh
In reply to this post by Andreas Reuleaux
On Thu, 06 Aug 2015 09:21:31 +0200, Andreas Reuleaux [via Asciidoctor ::  
Discussion] <[hidden email]> wrote:

it seems there is no problem in the first place, no? actually

"here is some _text__ containing a word with trailing underscore"

renders just as expected (note that `text' is preceded by a single, and  
followed by two underscores). problems only arise if there is more than  
one emphasized word
in a single input line (because sucessive pairs of `_' are interpreted as  
bracketing the to-be-emphazised text). actually, that's exactly what is  
happening in your example.... I believe that can be solved via some  
quoting but I'd rather break such lines so that each input line does  
contain only a single instance of your `expr_' type words (without any  
other `_foobar_' instances).

hth

j.


>
>
> Hi,
>
> How would I do the following formatting:
>
> some of my words deliberatly end with single underscores:
> but I would the whole word to be emphasized:
>
> Here is an example of my text:
>
>   the expr parser parses expressions, while the expr_
>   parser is its white space aware counterpart.
>
> Now I want both: expr and expr_ to be emphasized.
>
> die html I want is
>
>   <em>expr<em> ... <em>expr_<em>
>
> while I found out that I can achieve that effect with
>  pass:[<em>expr_</em>]
>
> this works only for the html rendering, the pdf is broken,
> I guess one can use some kind of function somewhere,
> that does distinguish between html and pdf rendering
> (pointers? - have never used that before).
>
> ideally I'd have something very short, like so
>
>   _expr_ ...  em:[expr_]
>
>
> that works for both html and pdf, as I write
> not only about expression parsers, but also
> about decls, and much more stuff in this manner.
>
> Thanks in advance, and please bear with me:
> I am relatively new to asciidoctor.
>
> -Andreas
>
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion  
> below:
> http://discuss.asciidoctor.org/emphasize-word-ending-in-single-underscore-tp3629.html
>
> To unsubscribe from Asciidoctor :: Discussion, visit  
>
Using Opera's revolutionary email client:
http://www.opera.com/mail/
Reply | Threaded
Open this post in threaded view
|

Re: emphasize word ending in single underscore

Andreas Reuleaux
Ah well, that makes sense, yes.

And thanks for your advice as well, to just
break longer lines in pieces that contain
at most one such expr_ thing.

-Andreas


"jvdh [via Asciidoctor :: Discussion]"
<[hidden email]> writes:

> On Thu, 06 Aug 2015 09:21:31 +0200, Andreas Reuleaux [via Asciidoctor ::  
> Discussion] <[hidden email]> wrote:
>
> it seems there is no problem in the first place, no? actually
>
> "here is some _text__ containing a word with trailing underscore"
>
> renders just as expected (note that `text' is preceded by a single, and  
> followed by two underscores). problems only arise if there is more than  
> one emphasized word
> in a single input line (because sucessive pairs of `_' are interpreted as  
> bracketing the to-be-emphazised text). actually, that's exactly what is  
> happening in your example.... I believe that can be solved via some  
> quoting but I'd rather break such lines so that each input line does  
> contain only a single instance of your `expr_' type words (without any  
> other `_foobar_' instances).
>
> hth
>
> j.
>
>
>>
>>
>> Hi,
>>
>> How would I do the following formatting:
>>
>> some of my words deliberatly end with single underscores:
>> but I would the whole word to be emphasized:
>>
>> Here is an example of my text:
>>
>>   the expr parser parses expressions, while the expr_
>>   parser is its white space aware counterpart.
>>
>> Now I want both: expr and expr_ to be emphasized.
>>
>> die html I want is
>>
>>   <em>expr<em> ... <em>expr_<em>
>>
>> while I found out that I can achieve that effect with
>>  pass:[<em>expr_</em>]
>>
>> this works only for the html rendering, the pdf is broken,
>> I guess one can use some kind of function somewhere,
>> that does distinguish between html and pdf rendering
>> (pointers? - have never used that before).
>>
>> ideally I'd have something very short, like so
>>
>>   _expr_ ...  em:[expr_]
>>
>>
>> that works for both html and pdf, as I write
>> not only about expression parsers, but also
>> about decls, and much more stuff in this manner.
>>
>> Thanks in advance, and please bear with me:
>> I am relatively new to asciidoctor.
>>
>> -Andreas
>>
>>
>>
>>
>> _______________________________________________
>> If you reply to this email, your message will be added to the discussion  
>> below:
>> http://discuss.asciidoctor.org/emphasize-word-ending-in-single-underscore-tp3629.html
>>
>> To unsubscribe from Asciidoctor :: Discussion, visit  
>>
Reply | Threaded
Open this post in threaded view
|

Re: emphasize word ending in single underscore

mojavelinux
Administrator
In reply to this post by Andreas Reuleaux

Andreas Reuleaux wrote:
Hm, yes, I have tried: _expr__
- worked for me sometimes, but not reliably,

I forgot to mention that sometimes it can get caught up with other uses. It was working fine in this particular case.

what circumstances exactly caused it two break, 

The problem is that double underscore has precedence over single underscore and since you've created that sequence, if you have two of them in a paragraph, you start to run into ambiguity.

These are the types of problems we believe will be solved (at least most of them) when we move to formal parser solution instead of regexp for inline parsing (see https://github.com/asciidoctor/asciidoctor/issues/61). However, keep in mind there will always be some edge cases as that is the trade-off for having lightweight markup. But that's where the passthrough functionality comes into play.

Other variations that I tried with some kind of \ - escaping didn't work out well either,

At the moment, Asciidoctor is very lazy about handling of backslashes (in favor of speed). This traces back to the regex approach for inline parsing (see https://github.com/asciidoctor/asciidoctor/issues/901). It's difficult to handle all but the simple cases in this way...so I think the passthrough is a better approach for now.

with your _pass:[expr_]_  I am now on the safe side: can use _expr__ when it works, and otherwise resort to _pass:[expr_]_ 

+1

Cheers,