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

Apply substitutions to source #4

Merged
merged 1 commit into from
Feb 11, 2022

Conversation

JaredReisinger
Copy link
Contributor

@JaredReisinger JaredReisinger commented Feb 10, 2022

(Note: I somehow got this fix on the wrong repo at first; see Deep-Symmetry/bytefield-svg#27. Here is where I actually intended it—but they apparently both need it.)

I ran into this in a document with a bunch of bytefield displays, where I wanted/needed to reduce the duplication of the same (defattrs ...) over and over again. By using:

:bytefieldDefaults: (defattrs :plain {:font-family "inherit" :font-size 14})

[bytefield,subs=attributes]
----
{bytefieldDefaults}

(draw-column-headers)
(draw-box "foo")
(draw-column-bottom)
----

I expected to be able to inject some common defaults. Instead, I got a "Could not resolve symbol: normal [at line 1, column 1]" error.

Digging into the code, I found that the extension.js line 15 was using attrs.subs as the "source" argument to $apply_subs(), rather than passing the original source. Using source here seems to fix things.

_(Note: I somehow got this fix on the wrong repo at first; see Deep-Symmetry/bytefield-svg#27.  _**Here**_ is where I actually intended it—but they apparently both need it.)_

I ran into this in a document with a _*bunch*_ of `bytefield` displays, where I wanted/needed to reduce the duplication of the same `(defattrs ...)` over and over again.  By using:

```
:bytefieldDefaults: (defattrs :plain {:font-family "inherit" :font-size 14})

[bytefield,subs=normal]
----
{bytefieldDefaults}

(draw-column-headers)
(draw-box "foo")
(draw-column-bottom)
----
```

I expected to be able to inject some common defaults.  Instead, I got a "Could not resolve symbol: normal [at line 1, column 1]" error.

Digging into the code, I found that the `extension.js` line 15 was using `attrs.subs` as the "source" argument to `$apply_subs()`, rather than passing the original source.  Using `source` here seems to fix things.
@brunchboy
Copy link
Member

Thanks again for finding and fixing this!

@brunchboy brunchboy merged commit a67737e into Deep-Symmetry:main Feb 11, 2022
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.

None yet

2 participants