ascii-only
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee
  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Charcoal tutorial draft <!-- Some kind of intro text here --> <!-- Mention that Charcoal uses a lot of non-ASCII characters, and point people to the code page. --> We'll start with examples in the Charcoal REPL. To use the REPL, simply run the command `./charcoal.py`, `python charcoal.py` or `python3 charcoal.py`. Note that `./charcoal.py` will not work on Windows. Alternatively, you can run `charcoal.py` from Idle. <!-- Is Idle a Windows-only thing, or does it work on Ubuntu too? --> ## Printing The central concept in Charcoal is printing strings to a canvas using a cursor. Any expression not preceded by a command is implicitly printed left-to-right. An expression preceded by one of the arrows `←↑→↓↖↗↘↙` is printed in that direction. Each print begins from the location where the previous one left off. Charcoal> foo foo Charcoal> ↘bar foob a r Note that the second and third lines are left-padded with spaces, and the first and second lines are right-padded. You can change the background character to something other than space; more on that later. After a few REPL commands, the canvas can get crowded. To clear it, hit <kbd>Ctrl</kbd>+<kbd>C</kbd> or use the `⎚` Clear command. Charcoal> ^C Cleared canvas Any run of printable ASCII--including space (`0x20`)--is a string literal. Strings can also include `¶`, which represents a newline. Charcoal> Hello, World!¶123 Hello, World! 123 Since the ASCII digits are used in string literals, integer literals consist of the superscript digits `⁰¹²³⁴⁵⁶⁷⁸⁹`. Printing an integer results in a line, using a character selected from `/\|-` based on the direction of printing. Charcoal> ⁷ ------- Charcoal> ↙³ -------/ / / ## Basic math To output a number instead of a line, we need the Cast operator `I`. This converts strings to numbers and vice versa. Charcoal> I⁴ 4 Arithmetic behaves mostly as expected, though the symbols are different: `⁺⁻×÷` and `X` for exponentiation. Division rounds down to the nearest integer. All operators are prefix. This sometimes creates the need to use the separator `¦` between operands to prevent them from being parsed as a single literal. Charcoal> I⁺⁴¦⁴ 8 Charcoal> ,I⁻⁴¦⁴ 8,0 Charcoal> ,I×⁴¦⁴ 8,0,16 Charcoal> ^C Cleared canvas Charcoal> I÷⁶¦⁴ 1 Charcoal> ,IX³¦³ 1,27 <!-- section on string overloads of arithmetic operators --> ## Variables A variable in Charcoal is any Greek lowercase letter from `αβγδεζηθικλμνξπρσςτυφχψω`. (Omicron was omitted because it looks too much like `o`.) You can assign values to them using the `A` command: Charcoal> A⁵β Charcoal> ×$β $$$$$ ## Input There are two ways to take input -- to store it as a variable, and to use it directly. If there is no variable after the command, it is treated as an operator with no arguments, returning the next input: Charcoal> N Input number: 5 ----- If there is a variable, input is instead stored in the variable, and nothing is returned. Charcoal> Nβ Input number: 3 Charcoal> β --- <!-- Only cover user input here. Talk about acceptable input formats. Talk about N and S, both in their command and expression usages. --> ## Control flow `¿` is the `if` command. It is followed by an expression (we shall call this `x`), and two bodies `y` and `z`, which are either an expression or multiple expressions surrounded by the double angle brackets `«»`. `y` gets executed if `x` evaluates to a truthy value, else `y` gets executed. Charcoal> ¿⁰foo¦bar foo Charcoal> ¿a«←ab»cd foba `F` is the `for` command. It is followed by an expression `x` and a body `y`. If `x` is a number, it is converted to a range from `0` to `x`, excluding `x` itself. Then, `x` is iterated over, `y` being run once for each element in `x`, the element being stored in the first free variable in `ικλμνξπρςστυφχψωαβγδεζηθ`. Charcoal> F²⁴na¦batman nanananananananananananananananananananananananabatman Charcoal> ^C Cleared canvas Charcoal> FHello, World!ײι HHeelllloo,, WWoorrlldd!! `W` is the `while` command. It is followed by an expression `x` and a body `y`. While `x` evaluates to truthy, `y` is run, the value of `x` being stored in `ικλμνξπρςστυφχψωαβγδεζηθ`. Charcoal>A¹⁰βWβ«⁺ι A⁻β¹β» 10 9 8 7 6 5 4 3 2 1 `HF` is `RefreshFor` - the same as `for` but with a numeric delay in milliseconds before `x`. Similarly, `HW` is `RefreshFor` - the same as `while` but with a numeric delay in milliseconds before `x`. Finally we have `⎇`, the ternary operator. This accepts three expressions `x`, `y` and `z`, returning `y` if `x` evaluates to true else `z`. Charcoal> ײ⎇¹b² bb ## More output commands Multiprint (`P`) acts the same as print except that it accepts a multidirection instead of a directions, which is either a list of directions multidirections (`+X*|-\/<>^KLTVY7¬`). Below is a list of directions and the directions they expand to: |Symbol|Directions| |-|-| |`+`|Right, Down, Left, Up| |`X`|Up Right, Down Right, Down Left, Up Left| |`*`|Right, Down Right, Down, Down Left, Left, Up Left, Up, Up Right| |`|`|Up, Down| |`-`|Left, Right| |`\`|Up Left, Down Right| |`/`|Up Right, Down Left| |`<`|Up Right, Down Right| |`>`|Down Left, Up Left| |`^`|Down Right, Down Left| |`K`|Up, Up Right, Down Right, Down| |`L`|Up, Right| |`T`|Right, Down, Left| |`V`|Up Left, Up Right| |`Y`|Up Left, Up Right, Down| |`7`|Down Left, Left| |`¬`|Down, Left| The general rule is the directions start from Right, and continue clockwise. The exceptions to this are `V` and `Y`. Charcoal> P*abc c c c bbb cbabc bbb c c c Rectangle (`UR`) creates a rectangle with the specified width and height, using `|` and `-` as edges and `+` as corners. Charcoal> UR⁵¦⁵ +---+ | | | | | | +---+ Box (`B`) creates a rectangle with the specified width and height, and using the specified characters as the edge, starting from the top edge. Charcoal> B⁵¦⁵¦abc abcab a c c a b b acbac Polygon (`G`) accepts a list of sides, which are alternating numbers and directions <!-- Polygon --> ## Other operators <!-- Or should this just be a link to the Operators wiki page? --> <!-- Probably? There are quite a few of them--> ## Other data types <!-- List, dictionary --> ## Cursor movement <!-- Move, Pivot, Jump --> ## Canvas operations <!-- Reflect, Rotate (& versions w/ copy and overlap), SetBackground --> ## Output control and animation <!-- Dump, Refresh, RefreshFor, RefreshWhile --> # README <!-- TODO: make this better --> Want to be able to write basic Charcoal quickly? Then read on. If you came here looking for help, scroll to the bottom for the FAQ. ## Example REPL session To use the REPL, simply invoke with `./charcoal.py`, `python charcoal.py` or `python3 charcoal.py`. Charcoal> Hello, World! Hello, World! Charcoal> ^C Cleared canvas ## Literals There are two basic types of literals: strings and numbers. A string is just a run of printable ASCII, and a number is just a run of the superscript digits `⁰¹²³⁴⁵⁶⁷⁸⁹`. Examples: `foo` is equivalent to `"foo"`. `foo¶bar` is the same as `"foo\nbar"`. `¹²³⁴` is `1234`. If you want to have two literals of the same type in a row, you need the delimiter character `¦`. Example: `¹¦¹` is parsed as `1` and `1`, not `11`. ## Printing In a Charcoal program, expressions are implicitly printed. Numbers print a line, and arrows can be used to specify a direction. Examples: `foo` prints `foo` `foo⁴` prints `foo----` `foo↖⁴` prints: ``` \ \ \ foo\ ``` ## FAQ - When I run Charcoal it throws some errors about UTF-8 characters and exits. - Maybe you don't have Python 3 installed. Try installing Python 3 from [here](https://www.python.org/downloads/windows/). - When I run Charcoal it throws some errors and exits. - If the message comes with a stack trace, it looks like you have found a bug. File a bug report [here](https://github.com/somebody1234/Charcoal/issues), and we'll come back to you as soon as we can. <!-- TODO: set up issue template -->

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully