question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding support for `fn:replace`

See original GitHub issue

I just looked into this. I would like to be able to use the functx library. I have gone through it and commented out all the functions that fontoxpath cannot currently compile. There are quite a lot, but they depend on a relatively few missing XQuery functions. The most interesting, for me, is replace.

I had a look at CONTRIBUTING.md and started to dig in. I see that the matches implementation uses xspatterns, which in turn relies on whynot. Currently, xspatterns only returns a boolean, which is enough for matches but not for replace. whynot in turn will return the traces that matched, which is enough for replace, but will still need some work to feed through xspatterns, which would also need extending to implement captures.

Meanwhile, I see that the fontoxpath implementation of tokenize does not use xspatterns at all, but JavaScript’s RegExp! (Again, not surprising, as xspatterns would not be sufficient in this case.)

I am unsure how to proceed.

I see that the implementation of matches does not support the flags argument; in the first instance, this is fine for me, as I don’t need flags for my use of replace.

I would be happy to implement replace using JavaScript regexes directly, which would be simple, but presumably not strictly XQuery-compliant. However, fontoxpath already does this for tokenize.

It looks fairly simple to extend xspatterns to return the match; but replace (and tokenize) need all the non-overlapping matching (effectively a g flag).

If you can let me know what would work for the fontoxpath maintainers, I can consider how I might be able to help; in the mean time, I suspect I will simply implement the desired functx functions directly in JavaScript. (In the first instance, I simply want trim: as you can see, I’ve already gone down quite a deep rabbit hole in an effort to see how to do this “properly”!)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
DrRataplancommented, Oct 1, 2021

It’s in! 3.21.0 has this!

0reactions
DrRataplancommented, Aug 30, 2021

~I just shipped a new release: 3.20.0. This includes basic support for the fn:pattern function. Thanks a lot for the help!!~

NVM, overlooked the fact this has not landed yet

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding Support Below a Settling Fireplace Hearth ... - Pinterest
Jun 28, 2014 - Adding Support Below a Settling Fireplace Hearth with an adjustable length steel column aka jackpost.
Read more >
HOW TO FRAME A FIREPLACE with TV mount support!!
Whether you're replacing an old fireplace or just want to build a new wall for a fireplace insert and TV, this video will...
Read more >
Structure support under fireplace | Hearth.com Forums Home
To add some additional support from below, I would screw 2 or 3 - 2x6 across the width of the barrel arch to...
Read more >
How to Add a Fireplace to Your Home for a Cozy Space
If you want to add a wood-burning fireplace, you need space above to get a chimney through the roof. In two-story houses, choices...
Read more >
framing strength under fireplace - Fine Homebuilding
It really depends on the load and how close to support below this will be. Just the brick floor load (with mortar bed)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found