Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #916. Add factory methods to create lists #917

Merged
merged 2 commits into from
May 2, 2020

Conversation

robertpanzer
Copy link
Member

Kind of change

  • Bug fix
  • New non-breaking feature
  • New breaking feature
  • Documentation update
  • Build improvement

Description

As @glisicivan identified in #916 that the Extension API is currently missing methods to create Lists.
This PR adds the missing methods.

How does it achieve that?

The PR adds the following method to Processor and a few overrides if no attributes or options are used:

org.asciidoctor.ast.List createList(StructuralNode parent, 
        String context, 
        Map<String, Object> attributes, 
        Map<Object, Object> options);

To create an ordered list "olist" must be passed as the context parameter.
For unordered lists "ulist" must be passed.

That means to create an ordered list simply call this from within an extension:

var list = createList(parent, "list");

Are there any alternative ways to implement this?

An alternative might have been to define methods like createUnorderedList(), createOrderedList() etc.
But passing the context as a String closer matches the API for createBlock() etc and is closer to the original Ruby API.

@mojavelinux Wdyt?

Issue

Fixes #916

@robertpanzer
Copy link
Member Author

I declared the createList API as experimental.
That way I can create a new release with the fix and wait for feedback without having to make major releases for bug fixes.

(I am not afraid of major releases, but I wouldn't want to go through several rounds of major releases because of missing feedback.)

@robertpanzer robertpanzer merged commit 521490a into asciidoctor:master May 2, 2020
@robertpanzer robertpanzer deleted the create-list branch May 2, 2020 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to create a list
1 participant