I am looking for a Markdown variant of the Htmlize addon.
The idea is simple: say, you wish to publish code to a GIST on GitHub, or any place which supports Markdown. You type your code in Emacs, do M-x markdownize-buffer and you get a new buffer containing the full Markdown markup.
Anybody knows if such an addon exists?
Markdown isn't powerful enough to generate span classes. To do this, you need to drop down into pure HTML.
Htmlize will generate a syntax-highlighted version of your code based on your current Emacs theme settings. Take a look at the generated markup: it does this by generating both DOM elements and styles to replicate your current syntax highlighting:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<!-- Created by htmlize-1.36 in css mode. -->
<html>
<head>
<title>sha1test.rb</title>
<style type="text/css">
<!--
body {
color: #eeeeec;
background-color: #2e3434;
}
.comment {
/* font-lock-comment-face */
color: #888a85;
}
.comment-delimiter {
/* font-lock-comment-delimiter-face */
color: #888a85;
}
/* [...] */
-->
</style>
</head>
<body>
<pre>
require <span class="string">'digest/sha1'</span>
<span class="type">SLICE_SIZE</span> = 20
<span class="keyword">def</span> <span class="function-name">myhash</span>(input)
<span class="type">Digest</span>::<span class="type">SHA1</span>.hexdigest(input).slice(0,<span class="type">SLICE_SIZE</span>)
<span class="keyword">end</span>
hashmap = {}
inputs = 0
unique_inputs = 0
<span class="type">ARGF</span>.each <span class="keyword">do</span> |line, idx|
[...]
</body>
</html>
Markdown can't replicate the kind of information here. It's good for translating semantic plain-text into semantic markup (i.e. headers should turn into H1 or H2, **text** should generate <strong>text</strong>, etc.). Which lines of your Emacs buffer are headers? Which should translate into <em> tags?
Related
I was looking to get open/click tacking using AMP for Emails
but yet to find any conclusive document to get any idea that how I can get tracking using AMP for emails.
Below is the sample code give by AMP but there is no tracking link of something given.
<!--
## Introduction
This sample demonstrates how to display a feed of data, allowing the user to go through
a large number of items in an email without having to scroll.
The sample uses a combination of [`amp-list`](/documentation/components/amp-list),
to fetch the initial items from the server and [`amp-form`](/documentation/components/amp-form),
to "refresh" a single item, by making a new server request.
-->
<!-- -->
<!doctype html>
<html ⚡4email lang="en" data-css-strict>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
<style amp4email-boilerplate>body{visibility:hidden}</style>
<!--
## Styles
We use CSS to hide the initially fetched item after the form is first submitted.
We also define a layout that allows us to have fixed card sizes, to ensure form submissions don't result in content jumps.
-->
<style amp-custom>
.amp-form-submit-success .initial-content,
.amp-form-submitting .initial-content,
.amp-form-submit-error .initial-content {
display: none;
}
.card {
width: 160px;
height: 120px;
margin: 10px;
float: left;
position: relative;
}
.card .next-button {
position: absolute;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<!--
## Single item template
Define a template for a single item inside a card and give it an `id`. This template is used by `amp-form` for displaying new items.
In this case, we use a single `amp-img`.
-->
<template id="item-template" type="amp-mustache">
<amp-img src="{{items.imageUrl}}" layout="fixed" width="160" height="90"></amp-img>
</template>
<!--
## Initial list of items
We define a template for the initial items and their layout and give it an `id`, allowing us to use it subsequently in an amp-list. This template is used by `amp-list` for fetching the initial up-to-date contents from the server.
It contains in itself an `amp-form` for each item which references the template defined above referred by its `id`. By using a different template for the `amp-form`, we're able to "refresh" a part of the content, namely the image in this case.
Note: This template contains the same markup (in this case, a single `amp-img`) as used in the template above to render the initial items. This is wrapped inside `<div class="initial-content">` which becomes hidden the first time the user submits the form.
-->
<template id="list-template" type="amp-mustache">
<form class="card" method="post" action-xhr="https://amp.dev/documentation/examples/api/photo-stream?single&width=160&height=90">
<div class="initial-content">
<amp-img src="{{imageUrl}}" layout="fixed" width="160" height="90"></amp-img>
</div>
<div submit-success template="item-template"></div>
<input class="next-button" type="submit" value="Next">
</form>
</template>
<!--
We use `amp-list` to render the initial items from the server using the template defined above referred by its `id`.
The height matches the combined height of our cards and their margins. The initial server response defines the number of cards to be displayed (in this case four).
-->
<amp-list template="list-template" src="https://amp.dev/documentation/examples/api/photo-stream?width=160&height=90&items=4" layout="fixed" width="360" height="280">
</amp-list>
</body>
</html>
Can anyone give a idea to implement tracking on this?
Thanks
The documentation says "AMPHTML allows tracking email opens with pixel tracking techniques, same as regular HTML emails."
There is therefore no specific AMP way of doing it--it's just normal.
So, normally the ESP handles open tracking, and perhaps click tracking too, by rewriting the URLs. Alternatively, you can add for example UTM links if you use Google Analytics on the site the links are going to.
I am trying to convert html to pdf using iText and getting below error.
Invalid span tag. Expected closing br tag
How is this an invalid xhtml ?
<span style="font-size: 10pt; line-height: 14.2667px;"><br/></span>
A span is an inline element, and a smallest element of xhtml tree.
styling tags like <u>, <i>, <strong> can be reside there.
A <br> or a <hr> is a full width element. Hence it is suggested to use <br> inside a <div></div>
I am using Confluence 5.10.8. On some pages I have several text snippets to be copied to the clipboard by the reader. For each of those text snippets I would like to be able to add a non-editable text field and a button to copy the text to the clipboard when clicking it, maybe like this:
I also need some visual feedback to indicate the text was copied.
I think a user macro is the right thing to do this, right? Something like (does not copy yet):
## #param Text:title=Text|type=string|required=true|desc=The text to be displayed and copied
<!-- font-awesome contains the clipboard icon -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<span style="white-space: nowrap">
<input type="text" value="$paramText" size="$paramText.length()" readonly>
<button class="fa fa-clipboard" title="click to copy">
</span>
I was able to solve this using clipboard.js. I am not sure why, but it did not work when adding the <script> tag directly to the macro. So instead I have added it to:
Confluence administration → Custom HTML → Edit ( /admin/editcustomhtml.action ) → At the end of the BODY
<!-- used by copy-text user macro to copy stuff to the clipboard -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.1/clipboard.min.js"></script>
Confluence administration → User Macros ( /admin/usermacros.action ) → Create a User Macro
## Macro title: text to copy
## Macro has a body: Y
## Body processing: Rendered
##
## Developed by: https://stackoverflow.com/users/1948252/
## Date created: 2018-06-28
## #param AllowLineWrap:type=boolean|default=false
## strip tags (in case they were pasted) to remove any formatting
#set ($body = $body.replaceAll("<.*?>",""))
#if ($paramAllowLineWrap == true)
#set ($whitespace = "normal")
#else
#set ($whitespace = "nowrap")
#end
<!-- for the clipboard icon etc. -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script>
window.onload=function()
{
var clipboard = new ClipboardJS('.copy-text-button');
clipboard.on("success", function(e)
{
console.log(e);
var button = $(e.trigger);
var title = button.prop("title");
button.addClass("fa-check-square");
button.html(" copied to clipboard");
function reset()
{
button.removeClass("fa-check-square")
button.html("");
}
window.setTimeout(reset, 5000);
});
clipboard.on('error', function(e) { console.log(e); });
}
</script>
<span class="panel" style="white-space: $whitespace;font-family:monospace;font-size:1em">
<span class="panelContent">$body</span>
<button class="copy-text-button fa fa-clipboard" data-clipboard-text="$body" title="click to copy">
</span>
Remarks:
In my first attempt I used a parameter and no body. But as it turned
out, template variables cannot be used in macro parameters. So the
usage of the macro was very limited. Therefore I removed the
parameter and enabled the body.
Body Processing has to be set to Rendered. I also tried the other options (Escaped and Unrendered), but those did not work together with template variables.
I replaced the initial text field by a simple span to be able to enable line wrap. This also solved issues with " characters in the body.
I use that font-awesome <link> to have some icons (clipboard and
check-square). At the first attempt I added the <link> to that
field on the Custom HTML page (because there is also the clipboard
<script>), but then the macro preview had no icon and thus looked
broken. So I decided to add it directly to the macro.
On editing a confluence page you can use it with
Ctrl+Shift+A and then enter the
macro name. Seems to work well with multiple usage on the same page.
Also works with template parameters.
Is there any way to change the font color in scribble with an HTML backend?
(More specifically, I want to put a large red WARNING label in the manual for a library.)
It turns out you can do this directly in scribble without using a backend dependent solution. The trick is to use styles that have color-property.
Using elem to set the style, as shown here, you can create a colorize function, that sets the color of your text.
(define (colorize #:color c . content)
(elem #:style (style #f (list (color-property c)))
content))
And then you could use it like this:
#colorize[#:color "red"]{WARNING}
There is also background-color-property you can sue to set the background of the text.
As Alexis mentioned, you can use a class paired with a Cascading Style Sheet (CSS) like so:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<!-- that's to link our styles to the webpage. -->
</head>
<body>
<!-- some time later... -->
<p class = "example">test</p>
<!-- the rest of the website -->
And in mystyle.css:
.example{ /* select all tags with the "example" class */
color: #FF0000; /* change font color using hex value */
background-color: #552222; /* change background color using hex value */
}
Now, this would be great if we were able to use multiple files. But, if you want to have it all in one file, we can send that same information in a <style> tag:
<head>
<!-- no need to link our styles, since they're embedded in the webpage. -->
</head>
<body>
<style>
.example{ /* select all tags with the "example" class */
color: #FF0000; /* change font color using hex value */
background-color: #552222; /* change background color using hex value */
}
</style>
<!-- some time later... -->
<p class = "example">test</p>
<!-- the rest of the website -->
There's another way to embed it, but you shouldn't use it. Ever. This is always the correct way.
See http://www.w3schools.com/css/css_examples.asp if you need anything more from the CSS side of things.
Manually creating a style struct containing an attributes property appears to work:
#lang scribble/base
#(require scribble/core
scribble/html-properties)
#para[#:style (style #f `(,(attributes '([style . "color:blue;"]))))]{blue text}
Hi am trying to design an accordion component using sightly in AEM where instead of jsp we write html code along with different file for css and js under client libs.
I simply coded the below written part and wrote js for the same but am not able to see any changes ... Could someone please provide me a solution to implement the same.. ->when i click on show a parsys section opens up and when show converts to hide and when i click on hide the parsys section closes and hide converts to show.
<div data-sly-use.clientLib="${'/libs/granite/sightly/templates/clientlib.html'}" data-sly-unwrap>
<css data-sly-call="${clientLib.css # categories=['sd-singtel.accordion_2']}" data-sly-unwrap/>
<js data-sly-call="${clientLib.js # categories=['sd-singtel.accordion_2']}" data-sly-unwrap/>
</div>
<div data-sly-test="${wcmmode.edit}">Accordion_2 component</div>
<div class="about-contentcontainer">
<div class="about-content">
<div class="awards">
<h4> <span class="more">Show</span></h4>
<h4> <span class="more expanded">Hide</span></h4>
</div>
</div>
</div>
<script>// <![CDATA[
$(document).ready(function() {
alert("Hello");
$(".awards h4 a").click(function() {
enter code here
$(this).parent().next().slideToggle("slow");
var htmlStr = $(this).find(".more").html();
if (htmlStr == "Show") {
$(this).find(".more").html("Hide");
$(this).find(".more").addClass("expanded");
} else {
$(this).find(".more").html("Show");
$(this).find(".more").removeClass("expanded");
}
});
});
// ]]></script>
Looking at it, I think that this has little to do with Sightly or even with AEM. Also, I'm not sure which content you want to toggle.
Below's a working HTML fragment for toggling content (independent from AEM):
<style>
.toggle-content {
display: block;
}
.toggle-content-hide,
.toggle-content-hidden .toggle-content-show {
display: inline;
}
.toggle-content-show,
.toggle-content-hidden .toggle-content-hide {
display: none;
}
</style>
<a href="#" class="toggle-content">
<span class="toggle-content-show">Show</span>
<span class="toggle-content-hide">Hide</span>
</a>
<div>Sample content 1</div>
<a href="#" class="toggle-content">
<span class="toggle-content-show">Show</span>
<span class="toggle-content-hide">Hide</span>
</a>
<div>Sample content 2</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
jQuery(function($) {
$('.toggle-content').click(function () {
$(this).toggleClass('toggle-content-hidden').next().toggle('slow');
return false;
})
});
</script>
To implement this in AEM, you should place the inline CSS into a CSS file of a client library, and the inline JS into a JS file of a client lib. I usually recommend to place them in the same client library within the component itself, so that everything that relates to that component is in the same folder. But when doing so, it is important to keep in mind that on a publish server, all /apps requests are forbidden by the dispatcher for security reasons, so all client libraries located under /apps should be merged and minified as one file that is typically located somewhere under /etc. To do so, you can use following repository node structure:
/apps/
mysite/
components/
mycomponent/
mycomponent.html Sightly template
clientlib/
jcr:primaryType = cq:ClientLibraryFolder
categories = [mysite.mycomponent]
css.txt contains just a reference to style.css
style.css contains the style snippet
js.txt contains just a reference to script.css
script.js contains the script snippet
/etc/
designs/
mysite/
clientlib/
jcr:primaryType = cq:ClientLibraryFolder
categories = [mysite.publish]
embed = [mysite.mycomponent, ...]
dependencies = [mysite.jquery]
The embed property of the /etc clientlib will make that it embeds and merges within the same file all clientlibs that are listed there. As opposed to the client libraries listed under the dependencies property, which will not get merged and will be served as a separate file. You can play with these properties to build the structure you need to optimize your site. There are also settings to automatically minify or not these files.
On the page, you then include the mysite.publish master clientlib located under /etc. So your page <head> element, would contain something like following Sightly template:
<head data-sly-use.clientLib="/libs/granite/sightly/templates/clientlib.html">
<sly data-sly-call="${clientLib.all # categories='sd-singtel.accordion_2'}" data-sly-unwrap/>
</head>
If you're using AEM 6.1, you can even drop the data-sly-unwrap, because the <sly> tag has the same effect.
After that, the Sightly template of your component located under a path like /apps/mysite/components/mycomponent/mycomponent.html would look as follows:
<div data-sly-test="${wcmmode.edit}">mycomponent name</div>
<a href="#" class="toggle-content">
<span class="toggle-content-show">Show</span>
<span class="toggle-content-hide">Hide</span>
</a>
<div>${properties.myContentProperty}</div>