-
Notifications
You must be signed in to change notification settings - Fork 30
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
[*] Asterisk not allowed/working handle name? #38
Comments
@mark-win Hi, thanks for the kind words about this library! I must admit that I never really saw the usage of
but I have an item in the Ideas issue #16 to provide configurable rules for name validation so that you can provide a regular expression to match what you want. If you need this functionality right now please change
I'll work on this in the near future, will keep you posted. :) |
Thank you for the quick response. I was a bit quick on the readme i guess. It is a different subject, but to keep your project as generic as possible, you might want to consider closure less line markers as well. To stay with the example of list elements, some implementations use |
Thanks for the work @thunderer , I'm planning on using your library in https://github.com/friendica/friendica, and we use the |
Hi @MrPetovan, I'm happy that it's useful for you. Can you confirm that asterisk works as expected in your environment? I'd like to close this issue and tag a new library version. Also, do you have any suggestions for this library? Feel free to create a new issue if there is anything you need or a way I could help. Thanks! |
Hi, I didn't start to use it yet, but you can expect me to tell you if it works as expected. I have one specific usage request: I'd like to be able to parse BBCode shortcodes in a text using the lexer, then look for URLs using a regular expression on the remaining text excluding the shortcodes, is that possible? Our use case is that we want to transform URLs into links in a text, but only if they aren't part of a shortcode already, either as an attribute or in the shortcode content itself. We're having problems with our home-brewed shortcode processor because we're using crude string replacements and basic regular expressions, so that's why I was interested in the lexer of this library. |
Thanks, I'm waiting for your confirmation then. As for processing URLs, I would like to know more about your use case. It definitely is possible, you can either:
Let me know what do you think, also text examples would allow me to propose a solution for your use case. |
For example, if I have the following input:
I would like the HTML output to be Here's <a href="https://example.com/a-link">a link</a>
and <img src="https://example.com/an-image.jpg" alt=""/>, but check this out also:
<a href="https://example.com/another-link">https://example.com/another-link</a> The last link isn't a shortcode but I'd still like to transform it into a link. Currently we are jumping through hoops to prevent other URLs present in the original text to be converted, and I expect your library to be able to parse the remaining text with a URL-matching RegExp after the ShortCode lexer is done. Parsing breakdown after the shortcode lexer based on the initial text:
After the URL-matching RegExp parser:
With the following parameters for shortcodes before handler execution:
|
I just tested the $RegularParser = new \Thunder\Shortcode\Parser\RegularParser();
$text = '[ul]
[*] Item 1
[*] item 2
[*] Item 3
[/ul]';
$result = $RegularParser->parse($text); Gives:
I suppose you thought about self-closing tags, but so far I haven't found how to specify it without the closing slash Additionally, the simple text |
For the issue with links, I suggest processing shortcodes as they are, ie. registering all handlers, processing the text and then operating on the result. Extracting URLs from the text is not a purpose of this library, but there are plenty available solutions for this, such as this StackOverflow question or anything under the term of "PHP linkify URL". |
As for the |
Oh, I forgot to explain that behaviour of this library with regard to your |
Thank you for your answers, what about the |
You said before that I don't mind replacing literal |
I just realized I haven't reached the Processor step yet. I thought the parser would handle the nested shortcodes but I realize now that it is done in the processor where the parser is called again on the content of the current level shortcodes. I just verified that the $RegularParser = new \Thunder\Shortcode\Parser\RegularParser();
$text = '[*] Item 1
[*] item 2
[*] Item 3';
$result = $RegularParser->parse($text); Gives:
As expected. You can close this issue, we can talk about the other problem in another one. |
@MrPetovan I'm happy that you solved the asterisks issue. I'm closing this one and moving on to the one you just opened. |
Hi, thanks for the project! I like it very much so far. Nonetheless, I'm having a hard Time registering some handles. Trying to register
[*]
as handle Name doesn't result in an Exception but neither does it seem to result in a working handle. It is not parsed from the input. For example:results in:
I tried escaping the asterisk as well. Is it me doing something wrong? I mean
[*]
is a pretty standard BBCode Element, isn't it? Would be a pain to replace it in WYSIWYG editors for this reason.Thanks, Mark.
The text was updated successfully, but these errors were encountered: