Making a clean looking Doxygen ALIAS with HTML - html

I have a working Doxygen ALIAS code using HTML (via #htmlonly), that in order to display a youtube video, allows me to simply write in the (".markdown")-file:
Youtube Link:
https://www.youtube.com/watch?v=**CODE**
With ALIAS:
#youtube{**CODE**}
Without ALIAS:
#htmlonly
<div align="center">
<iframe
title="my title" width="560" height="349"
src="http://www.youtube.com/embed/**CODE**?rel=0&loop=1"
frameborder="0" allowfullscreen align="middle">
</iframe>
</div>
#endhtmlonly
By adding the following ALIAS to the Doxyfile:
ALIASES += youtube{1}="#htmlonly<div align='center'><iframe title='my title' width='560' height='349' src='http://www.youtube.com/embed/\1?rel=0&loop=1' frameborder='0' allowfullscreen align='middle'></iframe></div>#endhtmlonly"
My problem is that the macro as you can see from above is HUGE and looks really CONFUSING!
Questions:
Is there a way to make it look clean?
What should I do with bigger HTML raw codes?
Should I be using any other Doxygen alternative to the ALIAS?

I managed to figure it out.
Instead of:
ALIASES += youtube{1}="#htmlonly<div align='center'><iframe title='my title' width='560' height='349' src='http://www.youtube.com/embed/\1?rel=0&loop=1' frameborder='0' allowfullscreen align='middle'></iframe></div>#endhtmlonly"
I can use:
#youtube{link}, with:
ALIASES+=addyoutube{1}="#htmlonly</p><div class='addYoutube'>\1</div>#endhtmlonly"
ALIASES+=youtube{1}="#addyoutube{\1} #htmlinclude add_youtube.html"
EXAMPLE_PATH += #CMAKE_CURRENT_SOURCE_DIR#/add_youtube.html
And add the following javascript code in a file in the current directory, add_youtube.html:
<script type="text/javascript">
var $getDiv = $('div.addYoutube').last();
var filmId = $getDiv.html()
filmId = filmId.replace("https://","")
filmId = filmId.replace("www.","")
filmId = filmId.replace("youtube.com/watch?v=","")
document.write("<div align='center'><iframe title='my title' width='560' height='349' src='http://www.youtube.com/embed/"+filmId+"?rel=0&loop=1' frameborder='0' allowfullscreen align='middle'> </iframe> </div>");
$getDiv.remove()
</script>

A bit to late for a party, but in Doxygen 1.8.12 it is possible to create some combination of doxygen tags #brief and HTML elements.
When you defining attributes for HTML elements it is possible to use apostrophes class='someClass' or you can also use quote sign with a backslash class=\"someClass\".
To indent the html use the string concantenation with a backslash sign \.
ALIASES += "briefWithImage{3} = #brief \
#htmlonly \
<span><img class='imgBriefImage' src='\1' alt='\1'></span> \
</span><span class='spanBriefText'>\2(<b>\3</b>)</span> \
#endhtmlonly"
I'm not sure about alternatives to aliases. One way is to define your custom HTML header for each page and when page is loaded - replace your own placeholders using custom JS functions.

Related

Iframe content does not load in Html widget in Flutter

I am using Html Widget to show article content in Flutter andriod app.Content is mixed html tag and contains some video embeded using iframe. Widget display a loading circle for a few seconds and after that nothing shown.
Flutter version 3.3.3
flutter_html: ^3.0.0-alpha.6
Sample Code expected to show in app:
<h3>View more</h3>
<p>This is a sample code for article and video inside artcle body</p>
<div class="h_iframe-aparat_embed_frame"><span style="display: block;padding-top: 57%"></span><iframe src="https://www.aparat.com/video/video/embed/videohash/q0IdU/vt/frame" allowFullScreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe></div>
<p>Click to view more video</p>
Have you try this?
var html = '''
<iframe width="1200" height='710'
src="$videosid" </iframe>
''';
Column(children:[
**HtmlWidget(html)** OR
InAppWebView(
InAppWebViewInitialData(data: '${html}'),
initialUrlRequest: URLRequest(
url: Uri.parse("${videosid}" ?? ''),
),
),
]
)

How to define a specific location in each item from loop ANGULAR

I created activity.json and I want to call data from json file. So, I made a ngFor loop in another file for getting the each item/data from json.
I thought it could get the location url-link from json file and put it to "<iframe src=" line of html file as a src link.
Following code, that mention about above issue.
[this is html file][1]
<div *ngFor="let seminer of activities">
<!-- <p>dive giriyor 6/6</p> -->
<h6>{{seminer.name}}</h6>
<iframe src="{{seminer.location}}" width="95%" height="225" style="border:0;" allowfullscreen="" loading="lazy"></iframe>
</div>
The spesific definition, this expression "{{seminer.location}}" couldn't accept as src link. How can I fix this issue. I mean I want to call each different location from json file.
[this is json file][2]
{
"activities":
[
{
"id":1,
"name":"Akınsoft Robotik Yarışması",
"location":"https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d97887.93596631498!2d32.725496907783025!3d39.9414344280414!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0xbda608ad56f1f424!2zQWvEsW5zb2Z0IEFua2FyYSBCw7ZsZ2UgTcO8ZMO8cmzDvMSfw7wtIEJpcmV5c2VsIEJpbGnFn2lt!5e0!3m2!1str!2str!4v1623673068413!5m2!1str!2str"
},
{
"id":2,
"name":"Parantez Teknoloji Arge Çalışması",
"location":"https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3059.4160712434614!2d32.829206315242146!3d39.932081979424524!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x14d34ec5db5faa51%3A0xc30ca1837518daa4!2sParantez%20Teknoloji!5e0!3m2!1str!2str!4v1623673296169!5m2!1str!2str"
},
{
"id":3,
"name":"Tusaş Ionic Mobil Tasarımlama",
"location":"https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3049.556596789323!2d32.651176815249194!3d40.15215957939679!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x408276c02c887105%3A0x1c5ec14c2922033f!2zR0FaxLAgw5xOxLBWRVJTxLBURVPEsCBUVVNBxZ4gS0FaQU4gTUVTTEVLIFnDnEtTRUtPS1VMVQ!5e0!3m2!1str!2str!4v1623673780177!5m2!1str!2str"
}
]
}
I guess the html tool don't let to use us a specific variable for routing a URL-link in other file. It has to used link in that place from direct, like this;
src="https://..."
I tried to different way for solving this issue. I tried to reach with different id's of each item. My solution is;
<iframe *ngIf="seminer.id==1" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d97887.93596631498!2d32.725496907783025!3d39.9414344280414!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0xbda608ad56f1f424!2zQWvEsW5zb2Z0IEFua2FyYSBCw7ZsZ2UgTcO8ZMO8cmzDvMSfw7wtIEJpcmV5c2VsIEJpbGnFn2lt!5e0!3m2!1str!2str!4v1623673068413!5m2!1str!2str" style="border:0;" allowfullscreen="" loading="lazy" class="center"></iframe>
<iframe *ngIf="seminer.id==2" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3059.4160712434614!2d32.829206315242146!3d39.932081979424524!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x14d34ec5db5faa51%3A0xc30ca1837518daa4!2sParantez%20Teknoloji!5e0!3m2!1str!2str!4v1623673296169!5m2!1str!2str" style="border:0;" allowfullscreen="" loading="lazy" class="center"></iframe>
<iframe *ngIf="seminer.id==3" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3049.556596789323!2d32.651176815249194!3d40.15215957939679!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x408276c02c887105%3A0x1c5ec14c2922033f!2zR0FaxLAgw5xOxLBWRVJTxLBURVPEsCBUVVNBxZ4gS0FaQU4gTUVTTEVLIFnDnEtTRUtPS1VMVQ!5e0!3m2!1str!2str!4v1623673780177!5m2!1str!2str" style="border:0;" allowfullscreen="" loading="lazy" class="center"></iframe>

Removing any videos from a HTML fragment

I have a (possibly not conforming to any standards) HTML fragment with embedded video. The problem is to remove the subfragment(s) with the video.
It is expected that the video follows this format:
<div data-oembed-url="https://www.youtube.com/watch?v=XXX&feature=youtu.be"><iframe allowfullscreen="allowfullscreen" frameborder="0" height="270" src="https://www.youtube.com/embed/XXX?feature=oembed" tabindex="-1" width=" 480"></iframe></div>
I am entirely unsure whether all data follows this scheme.
I think any div or p containing only the video should be removed, too.
Please help to write Perl code to remove video. Which Perl module do you recommend to use for parsing?
sub RemoveVideo {
my ($str) = #_;
my $attrRe = qr/\s*(?<name>\b\S+\b)\s*=\s*(?<value>"[^"]*"|'[^']*'|[^"'<>\s]+)\s*/;
my $iframeRe = qr{<iframe\b($attrRe)*>\s*</iframe\s*>|<iframe\b($attrRe)*\s*/>}i;
my $divRe = qr{<div\b($attrRe)*>\s*$iframeRe\s*</div\s*>\s*}i;
my $pRe = qr{<p\b($attrRe)*>\s*$iframeRe\s*</p\s*>\s*}i;
$str =~ s/$divRe//gms;
$str =~ s/$pRe//gms;
$str =~ s/$iframeRe//gms; # "голый" iframe (не внутри дива)
return $str;
}
my $Test = <<EOF;
XXX
<IFRAME allowfullscreen="allowfullscreen" frameborder="0" height="270" src="https://www.youtube.com/embed/XXX?feature=oembed" tabindex="-1" width=" 480"></iframe>
<div data-oembed-url="https://www.youtube.com/watch?v=XXX&feature=youtu.be"><iframe allowfullscreen="allowfullscreen" frameborder="0" height="270" src="https://www.youtube.com/embed/XXX?feature=oembed" tabindex="-1" width=" 480"></iframe></div>
<p data-oembed-url="https://www.youtube.com/watch?v=XXX&feature=youtu.be"><iframe allowfullscreen="allowfullscreen" frameborder="0" height="270" src="https://www.youtube.com/embed/XXX?feature=oembed" tabindex="-1" width=" 480"></iframe></p>
YYY
EOF
print RemoveVideo($Test);

Insert html in the output of smarty mailto function

I know how to use the smarty mailto function to create mailto anchor links with encoding. But I am wondering if it is possible for example to insert html image tags [<img>] into the output of this function.
I have tried:
[SMARTY]
{$text = '<img src="/images/qr_code.jpg" alt="member sign up qr code">'}
{mailto address="test#example.com" encode="hex" text={$text}}
[HTML RESULT]
<a href="mailto:%74%65%73%74#%65%78%61%6d%70%6c%65.%63%6f%6d">
<img src="/images/qr_code.jpg"
alt="member sign up qr code" >
</a>
I am after this output rather:
<a href="mailto:%74%65%73%74#%65%78%61%6d%70%6c%65.%63%6f%6d">
<img src="/images/qr_code.jpg"
alt="member sign up qr code">
</a>
It seems, from reading this code https://bitbucket.org/pferor/dbless/src/04b228943e39/dbless/lib/smarty/plugins/function.mailto.php, that when you use the "hex" encoding it not only encodes the address but also the text (line 147):
$text_encode = '';
for ($x=0; $x < strlen($text); $x++) {
$text_encode .= '&#x' . bin2hex($text[$x]).';';
}
Not sure if that's the problem though.
If you don't mind editing the Smarty source youmight be able to change this line (153):
return '<a href="'.$mailto.$address_encode.'" '.$extra.'>'.$text_encode.'</a>';
To this:
return '<a href="'.$mailto.$address_encode.'" '.$extra.'>'.$text.'</a>';
To make it work.
If you try "none" encoding does it show the image then?

How to return text from nokogiri without parsing it

I have html that looks like this:
<textarea id='embed'>
<iframe frameborder='0' width='728' height='450' src='http://somelink'>
</iframe> some more text
</textarea>
My code is:
doc.at('textarea[#id="embed"]').content
however this returns some more text
I want to fetch the entire text area (including the iframe link as it is). So finally I want this :
<iframe frameborder='0' width='728' height='450' src='http://somelink'>
</iframe> some more text
Use .inner_html.
[1] pry(main)> require 'nokogiri'
=> true
[2] pry(main)> noko = Nokogiri::HTML("<textarea id='embed'>
[2] pry(main)* <iframe frameborder='0' width='728' height='450' src='http://www.dailymotion.com/embed/video/xvnu79'>
[2] pry(main)* </iframe> some more text
[2] pry(main)* </textarea>");
[3] pry(main)> noko.css("#embed").inner_html
=> "<iframe frameborder=\"0\" width=\"728\" height=\"450\" src=\"http://www.dailymotion.com/embed/video/xvnu79\">\n </iframe> some more text\n"
Edit: you can use .inner_html with the XPath selector you have above too.