-
-
Notifications
You must be signed in to change notification settings - Fork 321
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
[Question] Can't seem to get SimpleTagHandler to work with custom html tags #235
Comments
Hello @wax911 ! Well, your handler is most likely being called, but the spans are not displayed. This case is actually handled by |
That makes sense 😄 In that case would that also apply to self terminating tags |
You mean the What kind of a mapper you are talking about? |
I see, thanks for the clarification!
Just a simple data mapper in my data layer for converting network models to application entities, just thought I could use some regex to add some dummy characters between the empty iframe tags |
If you do not control the content, then yes, adding a dummy character (even P.S. leaving it here as you'd mentioned regex and parsing html in one sentence 😄 |
🤣 the rabbit hole goes deep, I'll do a little bit of research see if I can find something light weight 😉 Thanks for heads up and help!! |
Thank you @noties 😃 just tested and it works everything works like a charm! Found a minor issue, it seems like if I have a tag handler for <html>
<head></head>
<body>
<p></p>
<h3>LiSA's Sword Art Online: Alicization OP Song "ADAMAS" Certified Platinum with 250,000 Downloads</h3>
<p></p>
<h5>The upper tune was already certified Gold one month after its digital release</h5>
<p>According to The Recording Industry Association of Japan (RIAJ)'s monthly report for April 2020, one of the <span
style="color: #ff9900;"><strong><a href="http://www.lxixsxa.com/" target="_blank"><span
style="color: #ff9900;">LiSA</span></a></strong></span>'s 14th single songs,
<strong>"ADAMAS"</strong> (the first OP theme for the TV anime <a href="/sword-art-online"
target="_blank"><span style="color: #ff9900;"><strong><em>Sword Art Online:
Alicization</em></strong></span></a>) has been certified <strong>Platinum</strong> for
surpassing 250,000 downloads.</p>
<p> </p>
<p>As a double A-side single with <strong>"Akai Wana (who loves it?),"</strong> <strong>"ADAMAS"</strong> was
released from SACRA Music in Japan on December 12, 2018. Its CD single ranked second in Oricon's weekly single
chart by selling 35,000 copies in its first week. Meanwhile, the song was released digitally two months prior to
its CD release, October 8, then reached Gold (100,000 downloads) in the following month.</p>
<p> </p>
<p> </p>
<center>
<p><strong>"ADAMAS"</strong> MV YouTube EDIT ver.:</p>
<p><iframe src="https://www.youtube.com/embed/UeEIl4JlE-g" frameborder="0" width="640" height="360"></iframe>
</p>
<p> </p>
<p>Standard edition CD jacket:</p>
<p><img src="https://img1.ak.crunchyroll.com/i/spire2/d7b1d6bc7563224388ef5ffc04a967581589950464_full.jpg"
alt="" width="640" height="635"></p>
</center>
<p> </p>
<hr>
<p> </p>
<p>Source: RIAJ press release</p>
<p> </p>
<p><em>©SACRA MUSIC</em></p>
<p> </p>
<p style="text-align: center;"><a href="https://got.cr/PremiumTrial-NewsBanner4"><em><img
src="https://img1.ak.crunchyroll.com/i/spire4/78f5441d927cf160a93e037b567c2b1f1559091520_full.png"
alt="" width="640" height="43"></em></a></p>
</body>
</html> Everything but the iframe gets rendered, might you have an idea why this happens? If I remove my internal class TagAlignmentHandler private constructor(): SimpleTagHandler() {
override fun getSpans(
configuration: MarkwonConfiguration,
renderProps: RenderProps,
tag: HtmlTag
): Any? = AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER)
override fun supportedTags(): List<String> = listOf("center")
companion object {
fun create() = TagAlignmentHandler()
}
} |
class CenterTagHandler extends TagHandler {
@Override
public void handle(@NonNull MarkwonVisitor visitor, @NonNull MarkwonHtmlRenderer renderer, @NonNull HtmlTag tag) {
if (tag.isBlock()) {
visitChildren(visitor, renderer, tag.getAsBlock());
}
SpannableBuilder.setSpans(
visitor.builder(),
new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER),
tag.start(),
tag.end()
);
}
@NonNull
@Override
public Collection<String> supportedTags() {
return Collections.singleton("center");
}
} it feels like |
That seems to work thanks again 😆 |
Behaviour
I've been having trouble getting markwon to register
iframe
tags, I've got bunch of html with some iframe that embed youtube content e.g.<iframe src="https://www.youtube.com/embed/luWcue3t2OU" width="640" height="360"></iframe>
I tried to debug the issue, by adding a breakpoint on
getSpans
but the method never ran, suggesting that no iframe tags were found. The html is fairly plain, consisting of a few basic tags.Here's an example of the input taken from an rss feed:
Reproduction
I have setup markwon as follows:
Besides this everything else works perfectly!
Thank you in advance 😺
The text was updated successfully, but these errors were encountered: