Giter Site home page Giter Site logo

euclio / aurelius Goto Github PK

View Code? Open in Web Editor NEW
84.0 5.0 8.0 3.54 MB

A complete solution for previewing markdown written in Rust.

License: Apache License 2.0

Rust 88.81% CSS 0.31% JavaScript 6.21% HTML 4.66%
rust websockets markdown editor-plugin

aurelius's Introduction

aurelius

aurelius is a complete solution for live-previewing markdown as HTML.

crates.io

This crate provides a server that can render and update an HTML preview of markdown without a client-side refresh. Upon receiving an HTTP request, the server responds with an HTML page containing a rendering of supplied markdown. Client-side JavaScript then initiates a WebSocket connection which allows the server to push changes to the client.

Full documentation may be found here.

This crate was designed to power vim-markdown-composer, a markdown preview plugin for Neovim, but it may be used to implement similar plugins for any editor. See vim-markdown-composer for a real-world usage example.

Acknowledgments

This crate is inspired by suan's instant-markdown-d.

Why the name?

"Aurelius" is a Roman gens (family name) shared by many famous Romans, including emperor Marcus Aurelius, one of the "Five Good Emperors." The gens itself originates from the Latin aureus meaning "golden." Also, tell me that "Markdown Aurelius" isn't a great pun.

Aurelia (gens) on Wikipedia.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

aurelius's People

Contributors

dimbleby avatar euclio avatar jasonm23 avatar lovesegfault avatar nickhu avatar polyzen avatar sunng87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aurelius's Issues

Incremental update

Some editors (nvim, xi) support sending plugins buffer data incrementally. We should support this and not require the client to send the entire document on every update.

provide simple usage examples for beginners

hello

i've looked everywhere, even in the vim plugin. its hard to understand how to make a simple example of the server running inside a working directory and rendering a folder of markdown files.

please provide some simple example usages in the readme of how to use the server.

i just want to make a simple application that uses this server to render markdown files from my projects.

Rendering checkboxes

I'm using vim-markdown-composer and I would like to render checkboxes like so

  • task
  • task

aurelius::Server freeze when sending "<a"

aurelius::Server freeze when sending <a.

To Reproduce

Run the following code. This program will freeze after printing listening on [::1]:xxxx.

use aurelius::Server;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut server = Server::bind("localhost:0")?;

    println!("listening on {}", server.addr());

    server.send("<a".to_owned())?;

    Ok(())
}

Environment

  • Arch Linux
  • rustc 1.45.2 (d3fb005a3 2020-07-31)
  • aurelius 0.7.2 and 07d8613

CommonMark attribute syntax

Not sure if this is the place to make this request, but I thought it could be useful to have the syntax provided by the CommonMark AttributesExtension available.

I am not sure if pulldown-cmark already supports this (they do support attributes on headings).

I frequently use this on images and currently vim-markdown-composer does not handle this kind of syntax.
E.g. when adding a class attribute to an image: ![](img/image_2022-06-05-16-47-34.png){.invert}. The attribute part is currently rendered as the string "{.invert}".

Provide a `Renderer` trait

The pulldown-cmark renderer and external renderer could be reimplemented in terms of this trait. It could also be extended to support formats beyond markdown, like plantuml.

Update Katex version

I think it's a good idea to update the KaTeX version. For me the \neq sign doesn't render correctly, and I think they solved it in later versions (issue 1491 in their repo)

Not more than one subscript per row

Hey,

I am using the latest version of aurelius and have trouble when writing formulas. In general, KaTeX works good, but when I put more then one subscript per row, the TeX code does not get parsed at all. The context seems not to matter, the simple x_1 x_2 breaks the same as a complex formula, whereas both work fine if there is only one subscript.
Also there is no difference if I use inline or displayed math.

I tried updating to the latest version of KaTeX but it did not change anything. In the demo on their homepage the examples work well, so I guess this is an issue in aurelius.

Can you reproduce this issue.

Thanks in advance!!!

Compilation failed

Hello,

I tried to run cargo build --release --verbose after installing the vim-instant-markdown plugin.

The process failed while compiling aurelius:

   Compiling aurelius v0.4.0
     Running `rustc --crate-name aurelius /home/syoh/.cargo/registry/src/github.com-1ecc6299db9ec823/aurelius-0.4.0/src/lib.rs --crate-type lib -C opt-level=3 -C metadata=d0bdee3f2210eb5a -C extra-filename=-d0bdee3f2210eb5a --out-dir /home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps --emit=dep-info,link -L dependency=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps --extern chan=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libchan-6382cb66d4dab318.rlib --extern websocket=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libwebsocket-f7d74d80d3be491f.rlib --extern url=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/liburl-513654a7ee4afefb.rlib --extern serde_json=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libserde_json-f1b5df5d9cfbe5f5.rlib --extern staticfile=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libstaticfile-7a3a23ae94585ac7.rlib --extern error_chain=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/liberror_chain-c492938462d04190.rlib --extern pulldown_cmark=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libpulldown_cmark-f38c963fa2e58502.rlib --extern serde=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libserde-1cba3ed43f4d5a5b.rlib --extern iron=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libiron-910b739eebbe70f8.rlib --extern lazy_static=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/liblazy_static-05c6535e411a431f.rlib --extern log=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/liblog-2d4ddd7d1c555abe.rlib --extern handlebars_iron=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libhandlebars_iron-c7d03e4f139b9f21.rlib --extern shlex=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libshlex-728ed491b75c23de.rlib --extern mount=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libmount-99264bdd5fa3a61c.rlib --cap-lints allow -L native=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/build/backtrace-sys-e4956d294e94bde6/out/.libs`
error[E0308]: mismatched types
   --> /home/syoh/.cargo/registry/src/github.com-1ecc6299db9ec823/aurelius-0.4.0/src/lib.rs:253:22
    |
253 |         command.args(shlex);
    |                      ^^^^^ expected &[_], found struct `shlex::Shlex`
    |
    = note: expected type `&[_]`
    = note:    found type `shlex::Shlex<'_>`

error: aborting due to previous error

error: Could not compile `aurelius`.

Caused by:
  process didn't exit successfully: `rustc --crate-name aurelius /home/syoh/.cargo/registry/src/github.com-1ecc6299db9ec823/aurelius-0.4.0/src/lib.rs --crate-type lib -C opt-level=3 -C metadata=d0bdee3f2210eb5a -C extra-filename=-d0bdee3f2210eb5a --out-dir /home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps --emit=dep-info,link -L dependency=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps --extern chan=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libchan-6382cb66d4dab318.rlib --extern websocket=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libwebsocket-f7d74d80d3be491f.rlib --extern url=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/liburl-513654a7ee4afefb.rlib --extern serde_json=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libserde_json-f1b5df5d9cfbe5f5.rlib --extern staticfile=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libstaticfile-7a3a23ae94585ac7.rlib --extern error_chain=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/liberror_chain-c492938462d04190.rlib --extern pulldown_cmark=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libpulldown_cmark-f38c963fa2e58502.rlib --extern serde=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libserde-1cba3ed43f4d5a5b.rlib --extern iron=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libiron-910b739eebbe70f8.rlib --extern lazy_static=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/liblazy_static-05c6535e411a431f.rlib --extern log=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/liblog-2d4ddd7d1c555abe.rlib --extern handlebars_iron=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libhandlebars_iron-c7d03e4f139b9f21.rlib --extern shlex=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libshlex-728ed491b75c23de.rlib --extern mount=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/deps/libmount-99264bdd5fa3a61c.rlib --cap-lints allow -L native=/home/syoh/.config/nvim/bundle/vim-markdown-composer/target/release/build/backtrace-sys-e4956d294e94bde6/out/.libs` (exit code: 101)

I am on Ubuntu 16.04 using neovim.

Enhancement: Support for other CSS styles with easy switching

Are there any plans to add few other CSS styles resembling other common outputs (especially LaTeX/PDF like paper-looking CSS or Scholarly Markdown CSS) and a tiny disappearing-without-mouse-movement drop-down list to choose one right on the preview page?

This would be a killer-feature, because with https://github.com/Kozea/WeasyPrint or similar converter, it would be easy to produce high-quality professional documents (including academic papers, thesis, documentation etc.).

Relicense under dual MIT/Apache-2.0

This issue was automatically generated. Feel free to close without ceremony if
you do not agree with re-licensing or if it is not possible for other reasons.
Respond to @cmr with any questions or concerns, or pop over to
#rust-offtopic on IRC to discuss.

You're receiving this because someone (perhaps the project maintainer)
published a crates.io package with the license as "MIT" xor "Apache-2.0" and
the repository field pointing here.

TL;DR the Rust ecosystem is largely Apache-2.0. Being available under that
license is good for interoperation. The MIT license as an add-on can be nice
for GPLv2 projects to use your code.

Why?

The MIT license requires reproducing countless copies of the same copyright
header with different names in the copyright field, for every MIT library in
use. The Apache license does not have this drawback. However, this is not the
primary motivation for me creating these issues. The Apache license also has
protections from patent trolls and an explicit contribution licensing clause.
However, the Apache license is incompatible with GPLv2. This is why Rust is
dual-licensed as MIT/Apache (the "primary" license being Apache, MIT only for
GPLv2 compat), and doing so would be wise for this project. This also makes
this crate suitable for inclusion and unrestricted sharing in the Rust
standard distribution and other projects using dual MIT/Apache, such as my
personal ulterior motive, the Robigalia project.

Some ask, "Does this really apply to binary redistributions? Does MIT really
require reproducing the whole thing?" I'm not a lawyer, and I can't give legal
advice, but some Google Android apps include open source attributions using
this interpretation. Others also agree with
it
.
But, again, the copyright notice redistribution is not the primary motivation
for the dual-licensing. It's stronger protections to licensees and better
interoperation with the wider Rust ecosystem.

How?

To do this, get explicit approval from each contributor of copyrightable work
(as not all contributions qualify for copyright, due to not being a "creative
work", e.g. a typo fix) and then add the following to your README:

## License

Licensed under either of

 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.

and in your license headers, if you have them, use the following boilerplate
(based on that used in Rust):

// Copyright 2016 aurelius developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

It's commonly asked whether license headers are required. I'm not comfortable
making an official recommendation either way, but the Apache license
recommends it in their appendix on how to use the license.

Be sure to add the relevant LICENSE-{MIT,APACHE} files. You can copy these
from the Rust repo for a plain-text
version.

And don't forget to update the license metadata in your Cargo.toml to:

license = "MIT/Apache-2.0"

I'll be going through projects which agree to be relicensed and have approval
by the necessary contributors and doing this changes, so feel free to leave
the heavy lifting to me!

Contributor checkoff

To agree to relicensing, comment with :

I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to chose either at their option.

Or, if you're a contributor, you can check the box in this repo next to your
name. My scripts will pick this exact phrase up and check your checkbox, but
I'll come through and manually review this issue later as well.

Feature suggestion: scroll browser view to "match" vim point in text.

Caveat emptor. With images, extensive katex/mathjax, unbroken lines in source text, etc. The relative browser page position will be indeterminate.

  • When the user moves the cursor in vim.
  • Given a vim-markdown-view session is open/active.
  • Then the browser should scroll to approximately the same location. (e.g. page percent)

It should also be optional/tune-able, to avoid too many renders.

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.