macro for todo items

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

macro for todo items

wimdeblauwe
Hi,

I am using this in a lot of places now:

icon:wrench[] _TODO: Something todo here_

I would like to be able to do something like:

todo:[] Something todo here

by defining that 'todo' should expand to the icon and the TODO and the italics stuff.

I have read up on macro's and such, but I am still unsure if want I want is possible and/or how to do it?

regards,

Wim
Reply | Threaded
Open this post in threaded view
|

Re: macro for todo items

wimdeblauwe
I managed to get this:

:todo-item: pass:normal[icon:wrench[] _TODO:_]

which allows me to do this:

{todo-item} Something that still needs to be done.

The only thing missing is that "Something that still needs to be done." is not in italic like "TODO" itself. Any idea on how to add that?
Reply | Threaded
Open this post in threaded view
|

Re: macro for todo items

mojavelinux
Administrator
My advice here is to write an inline macro extension that processes syntax similar to this:

[source,asciidoc]
----

todo:[Something that still needs to be done.]

----

I've selected a syntax that closely resembles a footnote.

You can study other inline macro extensions (labeled as such) in the extensions lab.

https://github.com/asciidoctor/asciidoctor-extensions-lab/tree/master/lib

One thing slightly different from existing examples is that you need to indicate you want the short form of the macro. Something like:

[source,ruby]
----

class TodoMacro < Extensions::InlineMacroProcessor
  use_dsl
  named :todo
  using_format :short
 
  def process parent, target, attrs
    ...
  end
end

----

At the moment, inline macros return the replacement string directly...so you can just return the HTML that you want. Of course, if you want to support other backends, you will need to check the backend and return the appropriate markup (for instance, DocBook if the backend is docbook).

I know we desperately need documentation for writing extensions. I promise you that I'm going to get serious about it as soon as a possibly can. However, if someone else wants to start to run with it, please don't hesitate to take the initiative. See https://github.com/asciidoctor/asciidoctor.org/issues/347

-Dan

On Mon, Jan 12, 2015 at 5:36 AM, wimdeblauwe [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I managed to get this:

:todo-item: pass:normal[icon:wrench[] _TODO:_]

which allows me to do this:

{todo-item} Something that still needs to be done.

The only thing missing is that "Something that still needs to be done." is not in italic like "TODO" itself. Any idea on how to add that?


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/macro-for-todo-items-tp2667p2669.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: macro for todo items

wimdeblauwe
Hi,

Thanks for that, but I am afraid that is a bit out of my league. What I have is good enough for my needs for now.

regards,

Wim 

2015-01-19 7:53 GMT+01:00 mojavelinux [via Asciidoctor :: Discussion] <[hidden email]>:
My advice here is to write an inline macro extension that processes syntax similar to this:

[source,asciidoc]
----

todo:[Something that still needs to be done.]

----

I've selected a syntax that closely resembles a footnote.

You can study other inline macro extensions (labeled as such) in the extensions lab.

https://github.com/asciidoctor/asciidoctor-extensions-lab/tree/master/lib

One thing slightly different from existing examples is that you need to indicate you want the short form of the macro. Something like:

[source,ruby]
----

class TodoMacro < Extensions::InlineMacroProcessor
  use_dsl
  named :todo
  using_format :short
 
  def process parent, target, attrs
    ...
  end
end

----

At the moment, inline macros return the replacement string directly...so you can just return the HTML that you want. Of course, if you want to support other backends, you will need to check the backend and return the appropriate markup (for instance, DocBook if the backend is docbook).

I know we desperately need documentation for writing extensions. I promise you that I'm going to get serious about it as soon as a possibly can. However, if someone else wants to start to run with it, please don't hesitate to take the initiative. See https://github.com/asciidoctor/asciidoctor.org/issues/347

-Dan

On Mon, Jan 12, 2015 at 5:36 AM, wimdeblauwe [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I managed to get this:

:todo-item: pass:normal[icon:wrench[] _TODO:_]

which allows me to do this:

{todo-item} Something that still needs to be done.

The only thing missing is that "Something that still needs to be done." is not in italic like "TODO" itself. Any idea on how to add that?


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/macro-for-todo-items-tp2667p2669.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/macro-for-todo-items-tp2667p2677.html
To unsubscribe from macro for todo items, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: macro for todo items

mojavelinux
Administrator
I understand...though it really isn't hard to make an extension. It's only a few more lines of code than what I included in my message in this case. Plus, I think it opens a lot of possibilities for the future. Asciidoctor loves extensions!

Cheers,

-Dan

On Mon, Jan 19, 2015 at 12:07 AM, wimdeblauwe [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi,

Thanks for that, but I am afraid that is a bit out of my league. What I have is good enough for my needs for now.

regards,

Wim 

2015-01-19 7:53 GMT+01:00 mojavelinux [via Asciidoctor :: Discussion] <[hidden email]>:
My advice here is to write an inline macro extension that processes syntax similar to this:

[source,asciidoc]
----

todo:[Something that still needs to be done.]

----

I've selected a syntax that closely resembles a footnote.

You can study other inline macro extensions (labeled as such) in the extensions lab.

https://github.com/asciidoctor/asciidoctor-extensions-lab/tree/master/lib

One thing slightly different from existing examples is that you need to indicate you want the short form of the macro. Something like:

[source,ruby]
----

class TodoMacro < Extensions::InlineMacroProcessor
  use_dsl
  named :todo
  using_format :short
 
  def process parent, target, attrs
    ...
  end
end

----

At the moment, inline macros return the replacement string directly...so you can just return the HTML that you want. Of course, if you want to support other backends, you will need to check the backend and return the appropriate markup (for instance, DocBook if the backend is docbook).

I know we desperately need documentation for writing extensions. I promise you that I'm going to get serious about it as soon as a possibly can. However, if someone else wants to start to run with it, please don't hesitate to take the initiative. See https://github.com/asciidoctor/asciidoctor.org/issues/347

-Dan

On Mon, Jan 12, 2015 at 5:36 AM, wimdeblauwe [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I managed to get this:

:todo-item: pass:normal[icon:wrench[] _TODO:_]

which allows me to do this:

{todo-item} Something that still needs to be done.

The only thing missing is that "Something that still needs to be done." is not in italic like "TODO" itself. Any idea on how to add that?


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/macro-for-todo-items-tp2667p2669.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/macro-for-todo-items-tp2667p2677.html
To unsubscribe from macro for todo items, click here.
NAML




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/macro-for-todo-items-tp2667p2678.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--