Git Product home page Git Product logo

Comments (11)

sorawee avatar sorawee commented on June 23, 2024 1

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.

sorawee avatar sorawee commented on June 23, 2024 1

This is a minimal example of what you are trying to do. It seems to work fine for me.

Screen Shot 2019-12-31 at 19 40 14

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.

jtangpanitanon avatar jtangpanitanon commented on June 23, 2024

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?

Screen Shot 2020-01-09 at 2 32 28 PM

<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.

jtangpanitanon avatar jtangpanitanon commented on June 23, 2024

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

Screen Shot 2020-01-09 at 3 13 41 PM

from pollen-users.

sorawee avatar sorawee commented on June 23, 2024

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:

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.

sorawee avatar sorawee commented on June 23, 2024

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.

jtangpanitanon avatar jtangpanitanon commented on June 23, 2024

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.

sorawee avatar sorawee commented on June 23, 2024

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.

jtangpanitanon avatar jtangpanitanon commented on June 23, 2024

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.

Thanks @sorawee . It seems to solve half of the problem :)

Screen Shot 2020-01-09 at 4 08 47 PM

#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.

sorawee avatar sorawee commented on June 23, 2024

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.

jtangpanitanon avatar jtangpanitanon commented on June 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.