Thread overview
Re: ddoc patterns
Apr 07, 2011
spir
Apr 07, 2011
bearophile
Apr 07, 2011
spir
Apr 07, 2011
Jacob Carlborg
Apr 07, 2011
spir
Apr 08, 2011
Jacob Carlborg
Apr 08, 2011
spir
April 07, 2011
On 04/07/2011 10:20 AM, spir wrote:
> Hello,
>
> In D stdlib's ddoc the idiom "$(D some d code) is constantly used. But it does
> not work by me. Not only it's not interpreted, but the contents are stripped
> out all together. (A *very* big bug of ddoc.)
> First, I'd like to know why.
> Second, there is another pattern $(D_CODE some d code), but it place the code
> on a separate block. Is this intended?
> Third, http://www.digitalmars.com/d/2.0/ddoc.html seems to imply one can define
> new patterns. How to do that? I tried following the example, but my code ends
> up interpreted and stripped out.

OK found it: pattern defs must be places under a "Macro:" section title.

I take the opprtunity to ask another question: does anyone know how to tag a *span* of text as literal/uninterpreted (either in html or css). The issue is <pre> makes a *block*, even if not inside a <div> or <p>; I desperately need the same feature for inline pieces of code.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com

April 07, 2011
spir:

> I take the opprtunity to ask another question: does anyone know how to tag a *span* of text as literal/uninterpreted (either in html or css). The issue is <pre> makes a *block*, even if not inside a <div> or <p>; I desperately need the same feature for inline pieces of code.

Try:

----------
code here
----------

Bye,
bearophile
April 07, 2011
On 04/07/2011 12:53 PM, bearophile wrote:
> spir:
>
>> I take the opprtunity to ask another question: does anyone know how to tag a
>> *span* of text as literal/uninterpreted (either in html or css). The issue is
>> <pre>  makes a *block*, even if not inside a<div>  or<p>; I desperately need
>> the same feature for inline pieces of code.
>
> Try:
>
> ----------
> code here
> ----------
>
> Bye,
> bearophile

This makes a block --just what I don't want.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com

April 07, 2011
On 2011-04-07 12:25, spir wrote:
> On 04/07/2011 10:20 AM, spir wrote:
>> Hello,
>>
>> In D stdlib's ddoc the idiom "$(D some d code) is constantly used. But
>> it does
>> not work by me. Not only it's not interpreted, but the contents are
>> stripped
>> out all together. (A *very* big bug of ddoc.)
>> First, I'd like to know why.
>> Second, there is another pattern $(D_CODE some d code), but it place
>> the code
>> on a separate block. Is this intended?
>> Third, http://www.digitalmars.com/d/2.0/ddoc.html seems to imply one
>> can define
>> new patterns. How to do that? I tried following the example, but my
>> code ends
>> up interpreted and stripped out.
>
> OK found it: pattern defs must be places under a "Macro:" section title.
>
> I take the opprtunity to ask another question: does anyone know how to
> tag a *span* of text as literal/uninterpreted (either in html or css).
> The issue is <pre> makes a *block*, even if not inside a <div> or <p>; I
> desperately need the same feature for inline pieces of code.
>
> Denis

Have a look at the CSS display property: http://w3schools.com/css/pr_class_display.asp

-- 
/Jacob Carlborg
April 07, 2011
On 04/07/2011 03:32 PM, Jacob Carlborg wrote:
> On 2011-04-07 12:25, spir wrote:
>> On 04/07/2011 10:20 AM, spir wrote:
>>> Hello,
>>>
>>> In D stdlib's ddoc the idiom "$(D some d code) is constantly used. But
>>> it does
>>> not work by me. Not only it's not interpreted, but the contents are
>>> stripped
>>> out all together. (A *very* big bug of ddoc.)
>>> First, I'd like to know why.
>>> Second, there is another pattern $(D_CODE some d code), but it place
>>> the code
>>> on a separate block. Is this intended?
>>> Third, http://www.digitalmars.com/d/2.0/ddoc.html seems to imply one
>>> can define
>>> new patterns. How to do that? I tried following the example, but my
>>> code ends
>>> up interpreted and stripped out.
>>
>> OK found it: pattern defs must be places under a "Macro:" section title.
>>
>> I take the opprtunity to ask another question: does anyone know how to
>> tag a *span* of text as literal/uninterpreted (either in html or css).
>> The issue is <pre> makes a *block*, even if not inside a <div> or <p>; I
>> desperately need the same feature for inline pieces of code.
>>
>> Denis
>
> Have a look at the CSS display property:
> http://w3schools.com/css/pr_class_display.asp

Great, does the trick!
But is there else really no other way to suspend interpretation as <pre>? I find this strange... how are we supposed to insert "code phrases" in the flow of normal text?

Denis
-- 
_________________
vita es estrany
spir.wikidot.com

April 08, 2011
On 2011-04-07 19:27, spir wrote:
> On 04/07/2011 03:32 PM, Jacob Carlborg wrote:
>> On 2011-04-07 12:25, spir wrote:
>>> On 04/07/2011 10:20 AM, spir wrote:
>>>> Hello,
>>>>
>>>> In D stdlib's ddoc the idiom "$(D some d code) is constantly used. But
>>>> it does
>>>> not work by me. Not only it's not interpreted, but the contents are
>>>> stripped
>>>> out all together. (A *very* big bug of ddoc.)
>>>> First, I'd like to know why.
>>>> Second, there is another pattern $(D_CODE some d code), but it place
>>>> the code
>>>> on a separate block. Is this intended?
>>>> Third, http://www.digitalmars.com/d/2.0/ddoc.html seems to imply one
>>>> can define
>>>> new patterns. How to do that? I tried following the example, but my
>>>> code ends
>>>> up interpreted and stripped out.
>>>
>>> OK found it: pattern defs must be places under a "Macro:" section title.
>>>
>>> I take the opprtunity to ask another question: does anyone know how to
>>> tag a *span* of text as literal/uninterpreted (either in html or css).
>>> The issue is <pre> makes a *block*, even if not inside a <div> or <p>; I
>>> desperately need the same feature for inline pieces of code.
>>>
>>> Denis
>>
>> Have a look at the CSS display property:
>> http://w3schools.com/css/pr_class_display.asp
>
> Great, does the trick!
> But is there else really no other way to suspend interpretation as
> <pre>? I find this strange... how are we supposed to insert "code
> phrases" in the flow of normal text?
>
> Denis

Do you always need <pre> for that. I guess it depends on what the code contains.

-- 
/Jacob Carlborg
April 08, 2011
On Thu, Apr 7, 2011 at 7:27 PM, spir <denis.spir@gmail.com> wrote:
> how are we supposed to insert "code phrases" in the
> flow of normal text?

<code></code> tags should be used for that (http://www.w3.org/TR/html401/struct/text.html#h-9.2.1). But I know nothing about ddoc so I don't know how to write macro that will use <code> instead of <pre>. Although I believe it's a piece of cake :)
April 08, 2011
On 04/08/2011 03:00 PM, Aleksandar Ružičić wrote:
> On Thu, Apr 7, 2011 at 7:27 PM, spir<denis.spir@gmail.com>  wrote:
>> how are we supposed to insert "code phrases" in the
>> flow of normal text?
>
> <code></code>  tags should be used for that
> (http://www.w3.org/TR/html401/struct/text.html#h-9.2.1).

Right, but IIUC unlike <pre> there is no guarantee for <code> contents not to be interpreted further. It's a "semantic hint" to the rendering engine (which is often used to perform syntax highlighting).

>  But I know
> nothing about ddoc so I don't know how to write macro that will use
> <code>  instead of<pre>. Although I believe it's a piece of cake :)

Yes:
	Macros:
	    CODE = <code>$0</code>

Denis
-- 
_________________
vita es estrany
spir.wikidot.com

April 08, 2011
On Fri, Apr 8, 2011 at 8:52 PM, spir <denis.spir@gmail.com> wrote:
> Right, but IIUC unlike <pre> there is no guarantee for <code> contents not to be interpreted further. It's a "semantic hint" to the rendering engine (which is often used to perform syntax highlighting).

AFAIK no major browser (A-grade browser) does nothing more with <code> than making it have monospaced font (i.e. look at default styles for all elements in webkit: http://trac.webkit.org/browser/trunk/Source/WebCore/css/html.css, you'll see <code> only has it's font-family defined, while <pre> has few others more, most notably white-space: pre; and display: block). And no browser supports rendering syntax highlighting (as I know of) for any computer language (there are user scripts and maybe extensions which does that but in no way is that default behavior).

It's true, <code> does have semantic hint, and that's "hey anything between <code> and </code> is a computer code!", which is I believe exact what you want - to display some code inline..
April 08, 2011
On Fri, Apr 8, 2011 at 8:52 PM, spir <denis.spir@gmail.com> wrote:
> Yes:
>        Macros:
>            CODE = <code>$0</code>

That's really nice! I might take a look at ddoc and try to write some useful macros if it's expressive enough...