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

preProcess like facility, or specific event, at saving? #418

Closed
iherman opened this issue Mar 29, 2015 · 4 comments
Closed

preProcess like facility, or specific event, at saving? #418

iherman opened this issue Mar 29, 2015 · 4 comments

Comments

@iherman
Copy link
Member

iherman commented Mar 29, 2015

On the technical level: is it possible and, if yes, how; if not, would it be possible to have a preProcess-like feature when saving to HTML? I.e., I could add some simple jQuery function that would be executed before generating the final (X)HTML (and of course the script would then be removed from the output)? Alternatively, is there an event that is raised when save happens, in which case a handler to that event could be added through the current preProcess?

Here is the use case we ran into: we have (on github, but that is a detail I guess) a family of specs we develop in parallel. These documents have tons to cross references to one another. As long as the documents are on the repo, the good approach is to use the github.io links for this, i.e., the editors' drafts would work as expected. However, when saving the files into HTML these cross references should be exchanged against their /TR equivalents.

It is relatively straightforward to write a jQuery function to change the href values, especially when we talk about 3-4 editors' drafts only. However, this function should be executed only when the file is dumped into HTML; hence my original question.

Of course, if the use case can be solved directly through some other means, that would be great, but I have the impression that there might be other use cases as well.

Thx.

/Cc @gkellogg

@halindrome
Copy link
Contributor

Super easy with an event. Here is an example from ARIA:

if (respecEvents) {
// Subscribe to ReSpec "save" message to set the mapping tables to
// view-as-single-table state.
respecEvents.sub ("save", function (details) {
mappingTableInfos.forEach (function (item) {
viewAsSingleTable (item);
});
});

Basically, just subscribe to the save event, then in the event handler
do whatever you want. The event is fired at the start of translation
into HTML / XHTML / XML. So you can actually look at the message you
receive to decide what type of save is being done if you care.

Hope this helps.

On Mar 29, 2015 3:50 AM, "Ivan Herman" notifications@github.com wrote:

On the technical level: is it possible and, if yes, how; if not, would it
be possible to have a preProcess-like feature when saving to HTML? I.e.,
I could add some simple jQuery function that would be executed before
generating the final (X)HTML (and of course the script would then be
removed from the output)? Alternatively, is there an event that is raised
when save happens, in which case a handler to that event could be added
through the current preProcess?

Here is the use case we ran into: we have (on github, but that is a detail
I guess) a family of specs we develop in parallel. These documents have
tons to cross references to one another. As long as the documents are on
the repo, the good approach is to use the github.io links for this, i.e.,
the editors' drafts would work as expected. However, when saving the files
into HTML these cross references should be exchanged against their /TR
equivalents.

It is relatively straightforward to write a jQuery function to change the
href values, especially when we talk about 3-4 editors' drafts only.
However, this function should be executed only when the file is dumped into
HTML; hence my original question.

Of course, if the use case can be solved directly through some other
means, that would be great, but I have the impression that there might be
other use cases as well.

Thx.

/Cc @gkellogg https://github.com/gkellogg


Reply to this email directly or view it on GitHub
#418.

@iherman
Copy link
Member Author

iherman commented Mar 29, 2015

Ah! These are the infos I did not have: that this save event is raised and that there is even a respec utility to add a callback. Thanks, I can certainly take it from here.

(Is that documented somewhere and I missed it?)

Thanks

I.


Ivan Herman
Tel:+31 641044153
http://www.ivan-herman.net

(Written on mobile, sorry for brevity and misspellings...)

On 29 Mar 2015, at 19:01, Shane McCarron notifications@github.com wrote:

Super easy with an event. Here is an example from ARIA:

if (respecEvents) {
// Subscribe to ReSpec "save" message to set the mapping tables to
// view-as-single-table state.
respecEvents.sub ("save", function (details) {
mappingTableInfos.forEach (function (item) {
viewAsSingleTable (item);
});
});

Basically, just subscribe to the save event, then in the event handler
do whatever you want. The event is fired at the start of translation
into HTML / XHTML / XML. So you can actually look at the message you
receive to decide what type of save is being done if you care.

Hope this helps.

On Mar 29, 2015 3:50 AM, "Ivan Herman" notifications@github.com wrote:

On the technical level: is it possible and, if yes, how; if not, would it
be possible to have a preProcess-like feature when saving to HTML? I.e.,
I could add some simple jQuery function that would be executed before
generating the final (X)HTML (and of course the script would then be
removed from the output)? Alternatively, is there an event that is raised
when save happens, in which case a handler to that event could be added
through the current preProcess?

Here is the use case we ran into: we have (on github, but that is a detail
I guess) a family of specs we develop in parallel. These documents have
tons to cross references to one another. As long as the documents are on
the repo, the good approach is to use the github.io links for this, i.e.,
the editors' drafts would work as expected. However, when saving the files
into HTML these cross references should be exchanged against their /TR
equivalents.

It is relatively straightforward to write a jQuery function to change the
href values, especially when we talk about 3-4 editors' drafts only.
However, this function should be executed only when the file is dumped into
HTML; hence my original question.

Of course, if the use case can be solved directly through some other
means, that would be great, but I have the impression that there might be
other use cases as well.

Thx.

/Cc @gkellogg https://github.com/gkellogg


Reply to this email directly or view it on GitHub
#418.


Reply to this email directly or view it on GitHub.

@halindrome
Copy link
Contributor

Yes. It is in the RepSpec documentation at
http://www.w3.org/respec/ref.html#events

On Sun, Mar 29, 2015 at 12:42 PM, Ivan Herman notifications@github.com
wrote:

Ah! These are the infos I did not have: that this save event is raised and
that there is even a respec utility to add a callback. Thanks, I can
certainly take it from here.

(Is that documented somewhere and I missed it?)

Thanks

I.


Ivan Herman
Tel:+31 641044153
http://www.ivan-herman.net

(Written on mobile, sorry for brevity and misspellings...)

On 29 Mar 2015, at 19:01, Shane McCarron notifications@github.com
wrote:

Super easy with an event. Here is an example from ARIA:

if (respecEvents) {
// Subscribe to ReSpec "save" message to set the mapping tables to
// view-as-single-table state.
respecEvents.sub ("save", function (details) {
mappingTableInfos.forEach (function (item) {
viewAsSingleTable (item);
});
});

Basically, just subscribe to the save event, then in the event handler
do whatever you want. The event is fired at the start of translation
into HTML / XHTML / XML. So you can actually look at the message you
receive to decide what type of save is being done if you care.

Hope this helps.

On Mar 29, 2015 3:50 AM, "Ivan Herman" notifications@github.com wrote:

On the technical level: is it possible and, if yes, how; if not, would
it
be possible to have a preProcess-like feature when saving to HTML?
I.e.,
I could add some simple jQuery function that would be executed before
generating the final (X)HTML (and of course the script would then be
removed from the output)? Alternatively, is there an event that is
raised
when save happens, in which case a handler to that event could be added
through the current preProcess?

Here is the use case we ran into: we have (on github, but that is a
detail
I guess) a family of specs we develop in parallel. These documents have
tons to cross references to one another. As long as the documents are
on
the repo, the good approach is to use the github.io links for this,
i.e.,
the editors' drafts would work as expected. However, when saving the
files
into HTML these cross references should be exchanged against their /TR
equivalents.

It is relatively straightforward to write a jQuery function to change
the
href values, especially when we talk about 3-4 editors' drafts only.
However, this function should be executed only when the file is dumped
into
HTML; hence my original question.

Of course, if the use case can be solved directly through some other
means, that would be great, but I have the impression that there might
be
other use cases as well.

Thx.

/Cc @gkellogg https://github.com/gkellogg


Reply to this email directly or view it on GitHub
#418.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#418 (comment).

Shane McCarron
halindrome@gmail.com

@iherman
Copy link
Member Author

iherman commented Mar 29, 2015

I will need a new pair of glasses... Thanks

@iherman iherman closed this as completed Mar 29, 2015
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

No branches or pull requests

2 participants