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

Improvements to section refs #90

Open
Andrew-Morozko opened this issue Feb 13, 2024 · 1 comment
Open

Improvements to section refs #90

Andrew-Morozko opened this issue Feb 13, 2024 · 1 comment
Labels
enhancement New feature or request fcl
Milestone

Comments

@Andrew-Morozko
Copy link
Contributor

Currently section refs are pretty useless: they can only override the meta block or the title of the base section. However, it's possible to track the position of blocks relative to the base attribute, allowing users to prepend/append content to the base:

section "B" {
    content text {
        text = "B"
    }
}

section ref "ABC" {
    content text {
        text = "A"
    }
    base = section.B
    content text {
        text = "C"
    }
}

document "test" {
    section ref {
        base = section.ABC
    }
}

Produces A\nB\nC\n

@Andrew-Morozko Andrew-Morozko added the enhancement New feature or request label Feb 13, 2024
@Andrew-Morozko Andrew-Morozko added this to the v0.4 milestone Feb 13, 2024
@traut traut added the fcl label Feb 17, 2024
@traut
Copy link
Member

traut commented Feb 17, 2024

I like the idea!

I would object to the base attribute position tracking though -- it will be confusing if the order of the attributes (base) is meaningful here but not anywhere else. We should avoid introducing special cases as much as possible, so I wonder if we can come up with a different, clearer, syntax.

Maybe section-specific blocks named prepend and append? They can be just syntactic sugars around embedded section blocks.

For example:

section "B" {
    content text {
        text = "B"
    }
}

section ref "ABC" {
    base = section.B

    prepend {
        content text {
            text = "A"
        }
    }
    append {
        content text {
            text = "C"
        }
    }
}

document "test" {
    section ref {
        base = section.ABC
    }
}

With this logic:

  • if prepend block is specified inside section block, it is treated as an embedded section block that is prepended to the sections / content blocks in the base block
  • if append block is specified inside section block, it is treated as an embedded section block that is appended to the sections / content blocks in the base block
  • if any sections / content blocks are defined in the ref block, they override the section / content all blocks in the base block

What do you think, @Andrew-Morozko?

@traut traut modified the milestones: v0.4, v0.6 Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fcl
Projects
None yet
Development

No branches or pull requests

2 participants