Comments (11)
Welcome to Pollen and Racket!
FYI, in Github issues, which use Markdown, you should use triple backtick when you want to show a fragment of code so that the code is displayed verbatim and not parsed as Markdown.
For your second question, put:
(define ($ . xs)
`(mathjax ,(apply string-append `("$" ,@xs "$"))))
(define ($$ . xs)
`(mathjax ,(apply string-append `("$$" ,@xs "$$"))))
in pollen.rkt
. Make sure that your pollen.rkt
either has (provide (all-defined-out))
or (provide $ $$)
(you probably want the former).
What happens to Example 2? Can you show me the output?
from pollen-users.
This is a minimal example of what you are trying to do. It seems to work fine for me.
Note that I have three files in the project directory: pollen.rkt
, template.html.p
, and test.html.pm
. In Pollen, the file extension is important. Not sure if the problem that you experienced is related to the fact that you name your file html.pp
.
from pollen-users.
Hi @sorawee , thanks for your nice answer. I tried to copy your solution, it kind of works but is slightly different than yours. Any ideas what went wrong?
<test.html.pm>
#lang pollen
◊(define-meta title "Hello World!")
Example 1: ◊h1{◊${\mathcal{O} = 2_{\alpha+1}}}
Example 2: ◊${|\psi\rangle = \sum_nc_n|n\rangle}
<pollen.rkt>
#lang racket
(provide (all-defined-out))
(define ($ . xs)
`(mathjax ,(apply string-append `("$" ,@xs "$"))))
(define ($$ . xs)
`(mathjax ,(apply string-append `("$$" ,@xs "$$"))))
<template.html.p>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$']]}});
</script>
<title>◊(select-form-metas 'title here)</title>
</head>
<body>
<h1>◊(select-from-metas 'title here)</h1>
◊(->html doc)
</body>
</html>
from pollen-users.
Also, another problem is when I try to add your suggestion in <pollen.rkt> in the template for "Typography for Laywers"
#lang pollen/mode racket/base
(require "scribblings/pollen-rkt.scrbl" pollen/tag)
(provide (all-from-out "scribblings/pollen-rkt.scrbl"))
(module setup racket/base
(provide (all-defined-out)) ;; <- don't forget this line in your config submodule!
(require pollen/setup racket/path)
(define (omitted-path? p) (path-has-extension? p #".sh")))
(provide ie-payment-warning)
(define (ie-payment-warning)
(define div (default-tag-function 'div))
(define p (default-tag-function 'p))
(define strong (default-tag-function 'strong))
◊div[#:class "ie reader-note"]{◊p{Because of security considerations, my payment links ◊strong{do not support Internet Explorer 11 or earlier}. Please use a different browser.}})
(define ($ . xs)
`(mathjax ,(apply string-append `("$" ,@xs "$"))))
(define ($$ . xs)
`(mathjax ,(apply string-append `("$$" ,@xs "$$"))))
with the following html.pm file
#lang pollen
◊(define-meta title "where do the rules come from?")
◊hanging-topic[(topic-from-metas metas)]{Professional typography}
Example 1: ◊h1{◊${\mathcal{O} = 2_{\alpha+1}}}
Example 2: ◊${|\psi\rangle = \sum_nc_n|n\rangle}
I get the following
from pollen-users.
Let me address your first comment first. That is not a Pollen issue. Different browser has different initial CSS style settings. I used Chrome when I took the screenshot above. If you use a different browser (e.g., Safari), that would explain the discrepancy.
FWIW, there are several CSS libraries that attempt to give a better default settings so that all browsers have the same appearance. For example:
- Reboot (as a part of the Bootstrap framework)
- Normalize.css
So I recommend loading one of these in template.html.p
(in the <head>
section) to make browsers appear in the same way.
from pollen-users.
For your second comment: did you add
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$']]}});
</script>
to your template.html.p
?
from pollen-users.
For your second comment: did you add
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script> <script type="text/x-mathjax-config"> MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$']]}}); </script>
to your
template.html.p
?
Yep this is my template.html.p
<!DOCTYPE html>
◊(define parent-page (parent here))
◊(define previous-page (previous here))
◊(define next-page (next here))
◊(define here-title (or (select-from-metas 'title here) (symbol->string here)))
◊(define toolbar? (not (select-from-metas 'toolbar-blank metas)))
◊(define (make-side-nav id url text)
◊div[#:class "nav-outer" #:id id]{◊(link (or url "") ◊div[#:class "nav-inner"]{◊div[#:class "nav-flex" text]})})
◊(define center-cell-width 14)
◊(define side-cell-width (/ (- 100 (+ 10 (* center-cell-width 2))) 2))
◊(local-require pollen/tag)
◊; the name `link` is already defined as a function that makes hyperlinks,
◊; so we use `make-default-tag-function` to make a literal `link` tag
◊(define literal-link (make-default-tag-function 'link))
◊(define (make-subnav children)
(apply ul #:class "subnav"
(for/list ([child (in-list children)])
(li (xref (select-from-metas 'title child))))))
◊(local-require css-tools)
<head>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$']]}});
</script>
<title>◊(select-form-metas 'title here)</title>
<meta charset="UTF-8">
<script type="text/javascript">
if (navigator.appVersion.indexOf("Win")!=-1) {
◊; got windows
document.write('<link rel="stylesheet" type="text/css" media="all" href="fonts/equity-a.css" />');
} else if (navigator.appVersion.indexOf("Mac")!=-1) {
if (navigator.userAgent.match(/iPad/i) != null) {
◊; got ipad
◊; style sheet for ipad 2
document.write('<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="fonts/equity-b.css" type="text/css" />');
◊; style sheet for ipad 3
document.write('<link rel="stylesheet" media="only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (-webkit-min-device-pixel-ratio: 2)" type="text/css" href="fonts/equity-a.css" />');
} else {
◊; got mac
document.write('<link rel="stylesheet" type="text/css" media="all" href="fonts/equity-b.css" />');
}
} else {
◊; got something else
document.write('<link rel="stylesheet" type="text/css" media="all" href="fonts/equity-a.css" />');
}
</script>
...
from pollen-users.
I believe the issue is that you didn't (provide (all-defined-out))
in pollen.rkt
. If you don't want to provide everything that you define in that file, you can also just (provide $ $$)
to selectively provide the two tags that you created.
from pollen-users.
I believe the issue is that you didn't
(provide (all-defined-out))
inpollen.rkt
. If you don't want to provide everything that you define in that file, you can also just(provide $ $$)
to selectively provide the two tags that you created.
Thanks @sorawee . It seems to solve half of the problem :)
#lang pollen/mode racket/base
(provide (all-defined-out))
(require "scribblings/pollen-rkt.scrbl" pollen/tag)
(provide (all-from-out "scribblings/pollen-rkt.scrbl"))
(module setup racket/base
(provide (all-defined-out)) ;; <- don't forget this line in your config submodule!
(require pollen/setup racket/path)
(define (omitted-path? p) (path-has-extension? p #".sh")))
(provide ie-payment-warning)
(define (ie-payment-warning)
(define div (default-tag-function 'div))
(define p (default-tag-function 'p))
(define strong (default-tag-function 'strong))
◊div[#:class "ie reader-note"]{◊p{Because of security considerations, my payment links ◊strong{do not support Internet Explorer 11 or earlier}. Please use a different browser.}})
(define ($ . xs)
`(mathjax ,(apply string-append `("$" ,@xs "$"))))
(define ($$ . xs)
`(mathjax ,(apply string-append `("$$" ,@xs "$$"))))
from pollen-users.
The problem is that Typography for Lawyers (henceforth TfL) has a lot of black magic that you really don't want. In this case, the problem is caused by the automatic hyphenation, which attempts to hyphenate your LaTeX code because it doesn't know that your code is not a prose that should not be tampered with. One way to fix the problem is to add mathjax
to the list of tags on this line in pollen-rkt.scrbl
to make the automatic hyphenation skips LaTeX code.
But again, you really don't want to base your project on TfL. TfL is in fact a quite unconventional Pollen project, e.g., using literate programming instead of writing code as usual. You probably won't need any of these features.
from pollen-users.
Wow it works like magic. Thanks @sorawee ! I just found TfL template is quite beautiful and as I don't have HTML background, I won't be able to design things from scratch.
from pollen-users.
Related Issues (20)
- render index.ptree with subdirectories changes directory (though not project root) HOT 8
- Is parallel mode known to crash a lot? HOT 1
- decode-elements with decode-paragraphs inserts spurious <p> when nesting lists? HOT 2
- multiple text arguments? HOT 5
- serialising txexprs? HOT 2
- Beautiful Racket Racket docs HOT 1
- Classic tangle/weave support a la org/babel-mode HOT 2
- Add source tag to default block-tags HOT 3
- Importing text from other sources HOT 2
- One source file → multiple outputs of same type? HOT 6
- Having a hard time with maps HOT 4
- Metadata on pagenodes (?) / how to render link traversal HOT 5
- Filling templates multiple times, à la mail-merge -- maybe a non-use case? HOT 3
- Inserting html comment with pollen command HOT 4
- splitf-txexpr: how to use the resulting txexpr HOT 2
- Windows: Set Pollen environment variable HOT 2
- execute shell command via preprocessor?
- Mildy Dynamic Websites
- opinions sought: costs & benefits of switching to self-hosted Git server? HOT 17
- Could not find MANIFEST for package source HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pollen-users.