-
Notifications
You must be signed in to change notification settings - Fork 17
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
[Suggestion]: Separate Macros and Attributes #38
Comments
Potential issues and workarounds:
|
I like the new inline macro syntax. But I don’t get the point of passing whole list item to the macro. Why would one want to pass
If they want to pass some ranged content to a macro in mid of the list, I think allowing ranged tags as list item content will solve that use-case.
I think not making different behavior for detached modifiers will also resolve the 2nd issue. If we have that “detached modifiers macros” conflicting with inline macros, what was the point of choosing |
For the same reason you may want to alter the attributes of a list item (not just the paragraph), you may also want to run a macro on a whole list item. This argument could extend to anything: why run a macro on a subheading, since that breaks the structure? Any macro invocation can break the structure, so embracing it in a consistent manner makes sense here :) |
For most cases, it is true, but we are talking about lists, and there is imaginary object “list” wrapping all those detached modifiers.
<ul>
<li>list item</li>
<macro>
<li>content</li>
</macro>
<li>list continues</li>
</ul> Now If they actually want to break the list, they can use strong carryover tag, I think there will be some use-cases where user do want to modify the individual list item while not breaking the list (e.g. when they want to shorten/automate the long attributes.) If so, wouldn’t it better to allow using macro inside the attribute list (
|
I think I agree with everything in the description above 👍 Just some comments below. Mostly a clarification: you speak about tasks in the text but I assume you meant all detached modifier attributes. You had the following example:
Why is it
Correct?
I see the intent but so far we have always tried to avoid duplicate means to achieve the same thing. And I would really not want to require a character for an undone task. Replying to boltless:
It's exactly the example given in the description:
Coloring the list item marker to the same color as the content is often done in WYSIWYG editors and we even do that in our syntax highlighting for headings. I think having the ability to do so is quite useful. EDIT: one more: in your examples you still used the |
I just wrote #37 (comment). How exactly do you classify
|
can’t remember if I’ve said this idea before, but can we replace the
will be
or
This allows us to more clearly distinguish between attribute syntax and carryover tag (macro) syntax, which now have different functions and purposes. before:
after:
btw null-list-item idea already has this feature without creating any new special grammar:
is a paragraph with attributes. ;) |
@mrossinek That still doesn't count as a use-case of applying macro to a list item. Styling is job of attributes, not macros. Macros are used to change the given object completely. It will most likely change the type of original object. |
This change is very large in scope, I encourage reading carefully.
In the existing spec, we have two carryover tag types. They serve two different purposes - for instance,
#color
would apply the colour to the existing object and to all children (e.g. subheadings), whereas+color
would only apply a colour to the existing object and not to children.This syntax is unfortunately very confusing and inconsistent across various objects. Does "children" include all paragraphs inside a heading, or does that only include subheadings? How do you apply a style only to a title? Or only to the content, but not the title?
This proposal alleviates all these issues with minimal breakages. In doing so, it refactors the following elements:
Attributes vs Macros
There has been some debate about the core internals of Norg's macro system and some concerns have been raised. Specifically, this concern revolves around abstract objects (AOs). An AO is an unrepresentable state in the Norg syntax. An example is the code block macro - it can't evaluate to any physical Norg markup, so it evaluates to an AO instead.
This behaviour is fine, but how do you then evaluate an AO properly? Take for instance
#color
- it can't return any Norg markup that physically colours the text, but it can return an AO which abstractly says "this will be coloured". To alleviate this, every macro can have an export function that allows it to implement custom export behaviour per language. Even then, how do you represent such a colour? If someone exports their Norg document to HTML, how do you colour the heading? That's the job of CSS, not HTML.For this reason, we propose to break the existing implementation into two groups. On the one hand you have macros, which do not change in any way as part of this proposal. On the other, we would like to add a new group of objects called attributes as part of this proposal.
Attributes
An attribute is an abstract property of an object - its name, its colour, its styles. The
+this
syntax is used to apply an attribute. Attributes don't do anything, they just specify some data about an object.Example:
Macros
Contrary to attributes, macros are functions. Macros are invoked using
#this
syntax. That means they consume the object and potentially produce completely new (and optionally unrelated) markup, or they produce an AO.This is fundamentally different from an attribute, which acts as a marker on some object.
Generalization of Attributes
#37 has one fatal flaw - it's not possible to apply a macro (and now by extension an attribute) on an item in a list (only on its content, which may be undesirable if one would like to change the colour of the list marker (
-
)). To alleviate this, the task syntax can be generalized to not just tasks, but any attribute. This also makes tasks themselves attributes, which provides an unprecedented level of generalization throughout the format.Therefore, to apply an attribute to a list item, one would use the following syntax:
Contrary to this example, which would only colour the paragraph
Hello, world!
Tasks are now also attributes, but this doesn't change the way we use them. Attribute names also permit various punctuation characters, so examples like
- (=) On hold
still work just fine.Undone Task
For compatibility's sake, special meaning is applied to undone items. An empty attribute list means an "undone item":
( )
.Additionally, extraneous delimiting markers can also implicitly describe undone tasks:
( |+ Tue 5th March)
or(+ Tue 5th March|)
(space is optional).Generalization of Macros
We now know that
( )
applies attributes. How does one run a macro on an individual list item, then? This is where the last part of the proposal comes into play: remove inline link targets (and find a different way of implementing them) and make< >
the counterpart of( )
.Thus, the following:
Would execute
my_macro
and pass the whole list item (not just the paragraph) as parameters to the macro.Similarly, attached modifier extensions can be renamed to attached modifier attributes and a
< >
counterpart can be provided:{? heading title}<if task>
. On top of all that, a standalone<>
marker would supercede the&variable&
syntax (now used for super verbatim, see #33) to invoke a macro in-place. This gives the added benefit of being able to provide parameters to the macro, for instance inline images! Example:Here's a photo: <image my-image.png>.
Conclusion
All in all, splitting macros into macros + attributes is a great combination that permits many positive changes to the specification.
The text was updated successfully, but these errors were encountered: