Here's the HTML file, it's truncated due to the content size and contained with an "img" tag at the end.
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<meta charset="utf-8"></meta>
<title>The Waste Land</title>
<link rel="stylesheet" type="text/css" href="wasteland.css" class="day" title="day"/>
<link rel="alternate stylesheet" type="text/css" href="wasteland-night.css" class="night" title="night"/>
</head>
<body>
<section epub:type="frontmatter" id="frontmatter">
<section epub:type="titlepage" id="titlepage">
<h1>The Waste Land</h1>
<div class="aut">T.S. Eliot</div>
<div epub:type="epigraph">
</div>
<p epub:type="dedication">For Ezra Pound: <span xml:lang="it">il migliorfabbro</span></p>
</section>
</section>
<section epub:type="bodymatter" id="bodymatter">
<section id="ch1">
<h2>I. THE BURIAL OF THE DEAD</h2>
<div>Looking into the heart of light, the silence.</div>
<div xml:lang="de" id="ln42">
<em>Od' und leer das Meer</em>.<a epub:type="noteref" class="noteref" href="#note-4">*</a>
</div>
</div>
<div class="linegroup">
<img src="www.href">The lady of situations.
</img>
<div>Here is the man with three staves, and here the Wheel,</div>
<div>And here is the one-eyed merchant, and this card,</div>
</div>
</section>
</body>
Here's my code
HtmlNodeCollection imgNodes= HTMLDoc.DocumentNode.SelectNodes("//img");
or
List<HtmlNode> imgNodes = HTMLDoc.DocumentNode.Descendants().Where(n => n.Name =="img").ToList();
Neither can retrieve any tags. What can i do?
Related
Template:
<!DOCTYPE html>
<html>
<head>
<title>App Name #yield('title')</title>
</head>
<body>
#section('content')
</div>
</body>
</html>
View:
#section('content')
#if(session('message'))
<p>{{session('message')}}</p>
#endif
#foreach ($posts as $post)
<h2> {{$post->title}}</h2>
<p>{{$post->body}}</p>
Edit
Delete
#endforeach
#endsection
I have used this code and get white screen how to solve this problem
make layout folder and layout file get only white screen no any error and output
MASTE PAGE:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta name="csrf-token" content="{{csrf_token()}}">
#yield('metas')
#yield('head')
#yield('style')
</head>
<title>#yield('title')</title>
<body class="skin-blue sidebar-mini">
#yield('body')
</body>
<footer>
#yield('footer')
#yield('script_whole')
</footer>
</html>
CHILD PAGES:
#extends('path.to.master_page')
#section('head')
//head elemetns here
#endsection
#section('style')
//style here
#endsection
#section('title', 'my_title')
#section('content')
//content elemetns here
#endsection
#section('footer')
//footer elemetns here
#endsection
#section('script_whole')
//scripts here
#endsection
and now every page that extends from MASTER_page, so should use #section
Instead of using
#section('content');
in main blade file use
#yield('content');
I'm trying to include a letter head in my PDF templates like so:
fragments/header.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Header</title>
</head>
<body>
<div id="header" class="clearfix" th:fragement="header(sender, name, address1, address2, today)">
<div id="header-left">
<img class="logo" src="app/src/main/resources/template/pdf/assets/logo.png"/>
<div id="recipient">
<p th:object="${sender}"><span th:text="*{name}"></span> - <span th:text="*{address1short}"></span> - <span th:text="*{address2}"></span></p>
<p th:text="${name}"></p>
<p>
<span th:text="${address1}"></span><br/>
<span th:text="${address2}"></span>
</p>
</div>
</div>
<div id="header-right" th:object="${sender}">
<p><strong th:text="*{name}"></strong></p>
<p>
<span th:text="*{address1}"></span><br />
<span th:text="*{address2}"></span><br />
<span class="label" th:text="*{phoneLabel} + ':'"></span><span th:text="*{phone}"></span><br />
<span class="label" th:text="*{faxLabel} + ':'"></span><span th:text="*{fax}"></span><br />
<span class="label" th:text="*{emailLabel} + ':'"></span><span th:text="*{email}"></span><br />
<strong><span th:text="*{internetLabel}"></span>: <span th:text="*{internet}"></span></strong>
</p>
<p>
<span th:text="*{court}"></span><br />
<span th:text="*{registryNr}"></span><br />
<span th:text="*{directorLabel}"></span>: <span th:text="*{director}"></span><br />
<span th:text="*{vatId}"></span><br />
</p>
<p><span th:text="*{todayPrefix}"></span> <span th:text="${today}"></span></p>
</div>
</div>
</body>
</html>
template.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8"/>
<title>Template</title>
<link rel="stylesheet" type="text/css" media="all" href="app/src/main/resources/template/pdf/assets/style.css"/>
</head>
<body>
<div th:replace="app/src/main/resources/template/pdf/fragments/header :: header(${sender}, ${name}, ${address1}, ${address2}, ${today})"></div>
<!-- omitted for brevity -->
</body>
</html>
Everything works fine when I put the header code in the template directly. But when I try to inlude it as a fragment, like above, I get the following Error:
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "app/src/main/resources/template/pdf/fragments/header.html" - line 9, col 6)
template.html is in the app/src/main/resources/template/pdf/ folder. I had to include css and image files with the full path (from the root of the project) to get them to work. I tried including the fragment with the full path (as above) and only fragements/header, but I get the same error each time.
Im using
spring-boot-starter-thymeleaf 2.1.1
thymeleaf 3.0.11
Stacktrace:
[removed bc of character limit]
UPDATE
The correct path for the fragment is (in my case) "template/pfd/fragment/header" (so, full path from resources folder). Also, there was a typo in th:fragement="header".
The fragment reference should not be absolute to your project, but relative to your thymeleaf template root. So instead of (assuming it is app/src/main/resources/template/ whre your thymeleaf templates are located)
th:replace="app/src/main/resources/template/pdf/fragments/header ..."
use
th:replace="pdf/fragments/header ..."
The common use is
<div th:replace="fragments/header :: header"><div>
Using Thymeleaf
I've a simple main layout:
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
#yield('style')
</head>
<body>
#include('layouts.frontend.partials.slider')
#yield('javascript')
</body>
</html>
layouts.frontend.partials.slider
#section('style')
<link rel="stylesheet" type="text/css" href="mystyle.css">
#append
#section('javascript')
<script></script>
#append
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide" data-swiper-autoplay="1000">Slide 1</div>
<div class="swiper-slide" data-swiper-autoplay="1000">Slide 2</div>
<div class="swiper-slide" data-swiper-autoplay="1000">Slide 3</div>
</div>
<div class="swiper-pagination"> </div>
<div class="swiper-button-prev"> </div>
<div class="swiper-button-next"> </div>
</div>
The #section('style') will be ignored while the #section('javascript') is working fine within the include file...
I've reduced both files (main and include) to a minimum and swapped the position of style and javascript without any difference
What seems to be working is to change to position from the #yield('style') to the body, like:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
#include('layouts.frontend.partials.slider')
#yield('javascript')
#yield('style')
</body>
Maybe it's not allowed to have #section in an include file?
What i want to archive is to have multiple partial includes with it's own css and javascript includes
Thanks
Here is another way to do, it's good because you have some flexibility.
You create a master template, put your main files
master.blade.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="">
#section('css')
<!-- some master css here -->
#show
</head>
<body>
#section('navbar')
#include('common.navbar')
#show
#yield('content')
#include('common.footer')
#section('js')
<!-- some js here -->
#show
</body>
</html>
The others childs extends the master, you'll have all your layout and can customize what you want:
Child blade
#extends('master')
#section('css')
#parent
<!-- more css -->
#endsection
#section('navbar')
#parent
#endsection
#section('content')
<!-- Main content goes here -->
#endsection
#section('js')
<!-- replace js and add my own -->
<!-- others js -->
#endsection
Did you try extending your child blade file to use the master template?
At the top of layouts.frontend.partials.slider did you put #extends('layout.master') (or whatever the path to your master template is?)
It could be an issue caused by the order in which you are including files. Wouldn't a simpler solution be to have a #yield('slider') in your master template and simply wrap the slider content in #section('slider') and drop the #include...?
Here's what I got... for some reason when I click the image map links they open up the page outside the iframe (as in it opens up as it's own page)
I've messed with it for a couple hours and went through about 20 pages but none of them specifically deal with image map links and none of them are helping.
The live link is here, I'm using firefox.
http://www.penumbra-productions.com
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Penumbra Productions</title>
<script src="Scripts/jquery-1.10.2.js" type="text/javascript">
</script>
<script type="text/javascript">
$(document).ready(function () {
$("#dropshadow").hide();
setTimeout(function () {
$("#dropshadow").fadeIn(1000)
}, 1500);
});
</script>
<link href="CSS/Penprocss.css" rel="stylesheet" type="text/css"/>
<style type="text/css">
body {
background-color: #CCC;
}
</style>
</head>
<body>
<div id="dropshadow">
<div id="wrapper">
<div id="header">
<a href="Index.html">
<img src="Images/PenproFull.jpg"
width="309" height="199"
alt="Penumbra Productions"
longdesc="http://penumbra-productions.com/Index.html"/>
</a>
<br/>
</div>
<div id="navigation">
<img src="Images/Navigation.jpg" width="1200" height="50" border="0" usemap="#Map"/>
<map name="Map" id="Map">
<area shape="photography" coords="29,5,252,43" href="photo.html" target="content"/>
<area shape="videography" coords="319,6,516,43" href="video.html" target="content"/>
<area shape="portfolio" coords="572,9,761,44" href="port.html" target="content"/>
<area shape="contact" coords="801,9,981,42" href="contact.html" target="content"/>
<area shape="about" coords="1020,9,1185,43" href="about.html" target="content"/>
</map>
</div>
<iframe id="content" src="main.html" width="1200" height="620" frameborder="0"></iframe>
<div id="footer"></div>
</div>
</div>
</body>
</html>
ok... all that needed to happen was to add the name="content" attribute to the iframe so the image map links could target it
Instead of using the target attribute of the area tag, try using an onclick handler.
...
<area shape="contact" coords="801,9,981,42" href="#" onclick="loadNow('contact.html')" />
<area shape="about" coords="1020,9,1185,43" href="#" onclick="loadNow('about.html') />
...
function loadNow(url) { document.getElementById('content').src=url; }
I am focused on the wrong layer of abstraction here, but can't figure out where.
I have this file views/pages/overview.html.erb
<%= stylesheet_link_tag "cust/coderay"%>
<h1>Overview</h1>
<hr>
Here's my code test:
<%= html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)%>
<hr>
Back <%=link_to "home", "home"%>.
<hr>
It took <%="%.3f" %(Time.now-#start_time)%> seconds to generate this page.
To my surprise, the pages renders like so:
When I view source on the page I get:
<!DOCTYPE html>
<html>
<head>
<title>Dash</title>
<link href="/assets/application-all.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/all/pages.css?body=1" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/pages.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="SydEiDhSNHuEE6vCfr4rajIksxBbqnm89sddC08msjs=" name="csrf-token" />
</head>
<body>
<h1>Overview</h1>
<hr>
Here's my code test:
<table class="CodeRay"><tr>
<td class="line-numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>
</pre></td>
<td class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Hello, world!</span><span style="color:#710">'</span></span></pre></td>
</tr></table>
<hr>
Back home.
<hr>
It took 0.006 seconds to generate this page.
</body>
</html>
Why is the bracketed css displaying as inline text? What should my usage of coderay look like here?
Many thanks -
Rails escapes your HTML by default in ERB templates. You need to turn off HTML escaping like so:
<%=raw CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table) %>
See more at this question and these release notes.