Giter Club home page Giter Club logo

Comments (1)

lihebi avatar lihebi commented on August 22, 2024

Here are some snippets that may be related:

iracket/private/jupyter.rkt

Lines 106 to 124 in d2ffb50

(define mime-type/c
(or/c 'application/json
'application/pdf
'application/xml
'image/gif
'image/jpeg
'image/png
'image/bmp
'image/svg+xml
'image/tiff
'text/csv
'text/html
'text/markdown
'text/plain
'text/rtf
'text/xml
'video/avi
'video/mpeg
'video/mp4))

iracket/private/kernel.rkt

Lines 133 to 135 in d2ffb50

(define (make-display-html v)
(define pin (value->special-html-input-port v))
(cons 'text/html (xexpr->string `(code ,@(port->contents pin)))))

iracket/private/kernel.rkt

Lines 154 to 174 in d2ffb50

;; value->special-html-input-port : Any -> InputPort
;; Pretty-prints the value to a pipe and returns the input end. Pretty-printing
;; produces mostly text, but images (and other convertible things) are embedded
;; as xexpr specials in the port.
(define (value->special-html-input-port v)
(define-values (pin pout) (make-pipe-with-specials))
(define (size-hook v d? out)
(cond [(and (convertible? v) (convert v 'png-bytes)) 1]
[else #f]))
(define (print-hook v d? out)
(define png-data (convert v 'png-bytes))
(define img-src (format "data:image/png;base64,~a" (base64-encode png-data)))
(define img-style
"display: inline; vertical-align: baseline; padding: 0pt; margin: 0pt; border: 0pt")
(write-special `(img ((style ,img-style) (src ,img-src))) out))
(parameterize ((pretty-print-columns 'infinity)
(pretty-print-size-hook size-hook)
(pretty-print-print-hook print-hook))
(pretty-print v pout))
(close-output-port pout)
pin)

from iracket.

Related Issues (12)

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.