TSE: How to write very simple MarkDown text + Latex mathematical formulas tex and show it in your web browser?

4 views
Skip to first unread message

knud van eeden

unread,
Mar 12, 2023, 5:14:28 PM3/12/23
to SemWare TSE Pro Text Editor
Hello,

FYIO:

1. Write your text in TSE

2. At the bottom add this line:

<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js"></script><script src="https://casual-effects.com/markdeep/1.13/markdeep.min.js?"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>

3. Save it with the extension .md.html

4. Load it in your web browser (e.g. Google Chrome)

5. Example:

**Example**

Welcome to Markdeep. It is the simple
way to write plain text with _style_.

*************************************
*                _______            *
* .-------.     /      /   .-----.  *
* | Write +-+->/ Edit ++->| Share | *
* '-------' ^ /______/ |   '-----'  *
*           |          |            *
*            '--------'             *
*************************************

1. Write a text document
2. Add the Markdeep line at the end
3. Save with file extension `.md.html`
4. Double-click to view

Learn more at

$ x = 3 * y $

$ \left( \nabla a\cdot \nabla b\right) \cdot \dfrac{\partial z}{\partial x}\cdot \dfrac{\partial x}{\partial y} $

<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js"></script><script src="https://casual-effects.com/markdeep/1.13/markdeep.min.js?"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>

6. Note: You might have to add the MarkDeep web site 
to the exclude list in your anti-virus software.

Inline image

with friendly greetings
Knud van Eeden






knud van eeden

unread,
Mar 12, 2023, 8:38:39 PM3/12/23
to SemWare TSE Pro Text Editor
Hello,

FYIO:

1. Highlight your block of (MarkDown and or Latex $...$) text 

2. Run this TSE program (all 1-liners)

3. That will start a browser with the result shown.


---

// library: block: change: copy: text: to: mark: down: mark: deep <description></description> <version control></version control> <version>1.0.0.0.5</version> 
// <version control></version control> (filenamemacro=chanblmd.s) [<Program>] [<Research>] [kn, ri, su, 12-03-2023 23:06:28]
INTEGER PROC FNBlockChangeCopyTextToMarkDownMarkDeepB( INTEGER bufferI )
 INTEGER B = FALSE
 STRING fileNameS[255] = "c:\temp\ddd.md.html" // change this
 IF ( NOT ( IsBlockInCurrFile() ) ) Warn( "Please mark a block" ) B = FALSE RETURN( B ) ENDIF // return from the current procedure if no block is marked
 PushPosition()
 PushBlock()
 Copy()
 GotoBufferId( bufferI )
 Paste()
 EndFile()
 AddLine( '<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js"></script>' )
 EndLine()
 InsertText( '<script src="https://casual-effects.com/markdeep/1.13/markdeep.min.js?"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>', _INSERT_ )
 SaveAs( fileNameS, _OVERWRITE_ )
 AbandonFile( bufferI )
 Dos( Format( "start", " ", QuotePath( fileNameS ) ), _DONT_PROMPT_ )
 PopBlock()
 PopPosition()
 B = TRUE
 RETURN( B )
END
//
PROC Main()
 INTEGER bufferI = 0
 PushPosition()
 bufferI = CreateTempBuffer()
 PopPosition()
 Message( FNBlockChangeCopyTextToMarkDownMarkDeepB( bufferI ) ) // gives e.g. TRUE
END

---

knud van eeden

unread,
Mar 12, 2023, 10:56:26 PM3/12/23
to SemWare TSE Pro Text Editor
Hello,
---

Now asking ChatGPT to convert this program to C

ChatGPT: "Can you write this Semware SAL program instead in C?"

Answer: "Sure, here's an equivalent program in C"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_FILENAME_LEN 255

int is_block_in_curr_file() {
    /* Check if a block is marked in the current file */
    /* ...implementation... */
}

void warn(const char* msg) {
    /* Display a warning message */
    /* ...implementation... */
}

void push_position() {
    /* Push the current position onto a stack */
    /* ...implementation... */
}

void push_block() {
    /* Push the current block onto a stack */
    /* ...implementation... */
}

void copy() {
    /* Copy the current block to the clipboard */
    /* ...implementation... */
}

void goto_buffer_id(int buffer_id) {
    /* Move the cursor to a specified buffer */
    /* ...implementation... */
}

void paste() {
    /* Paste the contents of the clipboard */
    /* ...implementation... */
}

void end_file() {
    /* Move the cursor to the end of the current file */
    /* ...implementation... */
}

void add_line(const char* line) {
    /* Add a line of text to the current file */
    /* ...implementation... */
}

void end_line() {
    /* Move the cursor to the end of the current line */
    /* ...implementation... */
}

void insert_text(const char* text, int insert_mode) {
    /* Insert text at the current cursor position */
    /* ...implementation... */
}

void save_as(const char* filename, int overwrite_mode) {
    /* Save the current file with a specified filename */
    /* ...implementation... */
}

void abandon_file(int buffer_id) {
    /* Abandon the changes to a specified buffer */
    /* ...implementation... */
}

void dos(const char* command, int prompt_mode) {
    /* Execute a command in the DOS shell */
    /* ...implementation... */
}

int fn_block_change_copy_text_to_markdown_markdeep_b(int buffer_id) {
    int b = 0;
    char filename_s[MAX_FILENAME_LEN] = "c:\\temp\\ddd.md.html"; // change this

    if (!is_block_in_curr_file()) {
        warn("Please mark a block");
        b = 0;
        return b;
    }

    push_position();
    push_block();
    copy();
    goto_buffer_id(buffer_id);
    paste();
    end_file();
    add_line("<!-- Markdeep: --><style class=\"fallback\">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src=\"markdeep.min.js\"></script>");
    end_line();
    insert_text("<script src=\"https://casual-effects.com/markdeep/1.13/markdeep.min.js?\"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility=\"visible\")</script>", _INSERT_);
    save_as(filename_s, _OVERWRITE_);
    abandon_file(buffer_id);
    dos("start c:\\temp\\ddd.md.html", _DONT_PROMPT_);
    pop_block();
    pop_position();

    b = 1;
    return b;
}

int main() {
    int buffer_id = 0;
    push_position();
    buffer_id = create_temp_buffer();
    pop_position();
    printf("%d\n", fn_block_change_copy_text_to_markdown_markdeep_b(buffer_id));
    return 0;
}

Reply all
Reply to author
Forward
0 new messages