Coder Social home page Coder Social logo

maddy's Introduction

maddy's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maddy's Issues

[Bug][Markdown]: My markdown is not being parsed correctly

Operating System

Windows

Compiler

MVSC

Compiler flags

std:c++17

maddy version

1.2.0 (latest)

Minimal Mardown example

Zote Engine

Zote is a 2D Game Engine developed for my final university assignment.


Features

  • Scene
  • Camera (Orthographic and Perspective)
  • Entities and Components
  • 2D Rendering
  • 2D Physics
  • Scripting System
  • Build System
  • Input System


Build

  • Ensure you are using Windows 64-bit
  • Ensure you have Visual Studio 2022 installed
  • Clone this project
  • Open the project's root folder
  • Run GenerateProjects.bat
  • Open Zote.sln
  • Build the Game project
  • Hit the play button and ✨Enjoy✨


Hello Zote

Window setup

Zote doesn't have an Editor yet. So if you want to create a brand new game some basic setup is required. In order to start writing code go to the Game project and open Game.cpp. Then, inside the Run method, create your first Window and call his Init() and StartLoop() methods.

Ref<Window> myWindow = MakeRef<Window>();
myWindow->Init();

//Your scene setup code goes HERE.

myWindow->StartLoop();

The window must be constructed as a reference. The Ref syntax is just a normal shared pointer. The StartLoop() method initialises the window loop. So if you write code after that function it won't execute until the Zote Window get's closed.

Running the application now should open an empty grey window.

First entity

In order to create entites a Scene instance is required. At this point you can't create multiple scenes. After the scene initialisation you can call the scene CreateEntity() method and start adding components to it.

Scene myScene(myWindow);
Entity zote = myScene.CreateEntity();
zote.AddComponent<SpriteComponent>("Textures/alex.png");

At this point by running the application you should be experiencing the pleasure of being in the presence of Alex, the creator of this high tech engine.

Script System

The script system is quite similar to the Unity Monobehiavours. Behind the scenes works with the ECS pattern but the usage is more simple. To start using scripts you must to add the ScriptComponent to your entity.

Then, you can create your script in new .h and .cpp separated files. The next example will show how to create a script that changes between two sprites:

SwitchBetweenSprites.h

#pragma once
#include <ZoteCommon.h>

using namespace Zote;

class SwitchBetweenSprites : public Script
{
public:
	cstr pathA = "Textures/csharp.png";
	cstr pathB = "Textures/cpp.png";
	float timeToSwitch = 1;

	void Start() override;
	void Update(float deltaTime) override;

private:
	
	Entity thisEntity;
	bool change = false;
	float currentTime = 0;

};

SwitchBetweenSprites.cpp

#include "SwitchBetweenSprites.h"

void SwitchBetweenSprites::Start()
{
	LOG("Script SwitchBetweenSprites started");
	thisEntity = GetEntity();
}

void SwitchBetweenSprites::Update(float deltaTime)
{
	auto& spriteComponent = thisEntity.GetComponent<SpriteComponent>();
	
	currentTime += deltaTime;

	if (currentTime < timeToSwitch)
		return;

	currentTime = 0;

	cstr path = change ? pathA : pathB;
	spriteComponent.AddTexture(path);
	change = !change;

	LOG("Sprite texture updated to: " << path);
}

When the script is ready go back to Game.cpp and don't forget to write the preprocessor statement, for this example: #include "Scripts/SwitchBetweenSprites.h". By using the AddScript() method you can attach the script to the script component. It is possible to call this function with multiple scripts to attach them to a single Entity. It's mandatory to create the script instance as a pointer. This is the final code inside the Run() method.

Ref<Window> window = MakeRef<Window>();
window->Init();

Scene scene(window);

Entity myEntity = scene.CreateEntity();
myEntity.AddComponent<SpriteComponent>();

auto& myEntity_Scripts = myEntity.AddComponent<ScriptComponent>();
myEntity_Scripts.AddScript(new SwitchBetweenSprites());

window->StartLoop();

By hitting the run button you should see, in first place a blank quad, and then the csharp and cpp textures switching in the screen.

What is not working? What did you try?

For the provided markdown is generting a unexpected outcome. For example, the headers are not being parsed.....

# Zote Engine

Zote is a 2D Game Engine developed for my final university assignment.




## Features
- Scene
- Camera (Orthographic and Perspective)
- Entities and Components
- 2D Rendering
- 2D Physics
- Scripting System
- Build System
- Input System




## Build
- Ensure you are using Windows 64-bit
- Ensure you have Visual Studio 2022 installed
- Clone this project
- Open the project's root folder
- Run GenerateProjects.bat
- Open Zote.sln
- Build the Game project
- Hit the play button and ✨Enjoy✨




## Hello Zote



### Window setup
Zote doesn't have an Editor yet. So if you want to create a brand new game some basic setup is required. In order to start writing code go to the Game project and open Game.cpp. Then, inside the Run method, create your first Window and call his Init() and StartLoop() methods.

`
Ref myWindow = MakeRef();
myWindow->Init();

//Your scene setup code goes HERE.

myWindow->StartLoop();
`

The window **must** be constructed as a reference. The Ref syntax is just a normal shared pointer. The StartLoop() method initialises the window loop. So if you write code after that function it won't execute until the Zote Window get's closed.


Running the application now should open an empty grey window.



### First entity
In order to create entites a Scene instance is required. At this point you **can't** create multiple scenes. After the scene initialisation you can call the scene CreateEntity() method and start adding components to it.

`
Scene myScene(myWindow);
Entity zote = myScene.CreateEntity();
zote.AddComponent("Textures/alex.png");
`


At this point by running the application you should be experiencing the pleasure of being in the presence of Alex, the creator of this high tech engine.



## Script System



The script system is quite similar to the Unity Monobehiavours. Behind the scenes works with the ECS pattern but the usage is more simple. To start using scripts you must to add the ScriptComponent to your entity.

Then, you can create your script in new .h and .cpp separated files. The next example will show how to create a script that changes between two sprites:



SwitchBetweenSprites.h
`
#pragma once
#include

using namespace Zote;

class SwitchBetweenSprites : public Script
{
public:
cstr pathA = "Textures/csharp.png";
cstr pathB = "Textures/cpp.png";
float timeToSwitch = 1;

void Start() override;
void Update(float deltaTime) override;

private:

Entity thisEntity;
bool change = false;
float currentTime = 0;

};
`
SwitchBetweenSprites.cpp
`
#include "SwitchBetweenSprites.h"

void SwitchBetweenSprites::Start()
{
LOG("Script SwitchBetweenSprites started");
thisEntity = GetEntity();
}

void SwitchBetweenSprites::Update(float deltaTime)
{
auto& spriteComponent = thisEntity.GetComponent();

currentTime += deltaTime;

if (currentTime < timeToSwitch)
return;

currentTime = 0;

cstr path = change ? pathA : pathB;
spriteComponent.AddTexture(path);
change = !change;

LOG("Sprite texture updated to: " << path);
}
`
When the script is ready go back to Game.cpp and don't forget to write the preprocessor statement, for this example: #include "Scripts/SwitchBetweenSprites.h". By using the AddScript() method you can attach the script to the script component. It is possible to call this function with multiple scripts to attach them to a single Entity. It's mandatory to create the script instance as a **pointer**. This is the final code inside the Run() method.
`
Ref window = MakeRef();
window->Init();

Scene scene(window);

Entity myEntity = scene.CreateEntity();
myEntity.AddComponent();

auto& myEntity_Scripts = myEntity.AddComponent();
myEntity_Scripts.AddScript(new SwitchBetweenSprites());

window->StartLoop();
`
By hitting the run button you should see, in first place a blank quad, and then the csharp and cpp textures switching in the screen.ññññ�

Much slower than MD4C

Hello! Thanks for this library. I was wondering why for the same text I got such a difference performance:

Maddy took 5304 milliseconds
Qt took 5 milliseconds

Maddy code:

std::stringstream markdownInput("some text...");
m_markdownParser->Parse(markdownInput);

Qt code:

QString markdownInput("some text...");
QTextDocument textDoc;
textDoc.setMarkdown(markdownInput);
textDoc.toHtml();

EDIT: By mistake I set it as a feature request.

Nor parsing table

What is the issue?

Why this not work and not return table?

#include <iostream>
//#include <memory>
#include <string>
#include "maddy/parser.h"

std::string ConvertMarkdownToHTML(const std::string& markdownInput) {
    // Configurazione opzionale
    std::shared_ptr<maddy::ParserConfig> config = std::make_shared<maddy::ParserConfig>();

    //config->enabledParsers &= ~maddy::types::EMPHASIZED_PARSER;
    //config->enabledParsers |= maddy::types::TABLE_PARSER;
    //config->enabledParsers |= maddy::types::HTML_PARSER;

    //config->enabledParsers &= ~maddy::types::ALL;

    std::istringstream markdownStream(markdownInput);

    std::shared_ptr<maddy::Parser> parser = std::make_shared<maddy::Parser>(config);

    std::string htmlOutput = parser->Parse(markdownStream);
    return htmlOutput;
}

int main(int argc, char** argv)
{
	const std::string markdownInput = "##TEST \nColumn One | Column Two \n---------- | ---------- \nRow Text 1 | Row Text 2 \nRow Text 3 | Row Text 4\n";//argv[1]
	std::string htmlOutput = ConvertMarkdownToHTML(markdownInput);
	std::cout << htmlOutput << "\n";
	return 0;
}

Support backslash for escaping

Maddy doesn't seem to support the use of backslash to escape characters that are otherwise used for formatting. It would be amazing to have that capability added.

Maddy performance

What is the issue?

First of all thank you for this great library!

I've selected it for conversion of Markdown to HTML for my own CGI site. However, conversion of relatively small 5 markdown files takes about 3 seconds. It is not very convenient, since I'm going to handle tens of them.

Do you have performance improvement in your plans?

Again, let me thank you for your library. It is very useful (mostly because it doesn't employ external dependencies and easy to call)

Code Blocks

First of all, thanks for this work -- it's very helpful.

Currently code blocks are supported with three backticks but the original markdown spec is that 4 spaces or a tab at the beginning of a line mark a code block and this does not appear to be supported. There are a lot of markdown documents that employ that approach -- is it possible to support this syntax?

Local image to data URI?

Minimal Code Example

![]( ./images/a.png)

to html5

<img  src="data:image/png;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOy...">

Conditions

If in absolute path or relative path, there exists such an image, generate its data URI instead of providing a link.

Description

convert image to base64 seems a bit annoying, is it possible to implement this feature?

Underscores in link URL translated to <em> tag

Minimal Code Example

[Plastic bag code](https://en.wikivoyage.org/wiki/Common_scams#Plastic_bag_code)

<a href="https://en.wikivoyage.org/wiki/Common<em>scams#Plastic</em>bag_code">Plastic bag code</a>

Conditions

. .
Operating System: Ubuntu 18.04
Compiler: g++ 7.4.0
Compiler flags: -std=gnu++11
maddy version: 59b808b

Description

It appears that maddy formats underscores before checking to see whether the text is a URL that should not be formatted.

[Bug][C++]: parser.h VERSION() functions exposed without namespace creates multiple libraries incompatibilities

Operating System

ALL

Compiler

ALL

Compiler flags

none

maddy version

1.2.0 (latest)

Minimal C++ example

static const std::string VERSION() { static const std::string v = "1.2.0"; return v; }

What is not working? What did you try?

This function has broken our builds due to our version defines. Please change this global function name to something more scoped to the project or local to the parser class which will not interfere with VERSION define which is used in many projects .Use #define MADDY_VERSION in capitals, otherwise use lowercase letters to not interfere with #define syntax.

This will ensure code compatibility with many other projects, as #define VERSION is generally used to define project version.

Parser fail to find a list if it is not explicitly in its own paragraph

Minimal Code Example

#include <iostream>
#include <string>
#include <maddy/parser.h>

int main(int argc, char* argv[])
{
    (void)argc;
    (void)argv;

    // Parser is not giving expected output
    std::string bad =
        "**Some Title**\n"
        "- List element 1\n"
        "- List element 2";
    std::stringstream badInput(bad);

    // Parser works as expected
    std::string good =
        "**Some Title**\n"
        "\n"
        "- List element 1\n"
        "- List element 2";
    std::stringstream goodInput(good);


    auto parser = std::make_shared<maddy::Parser>();
    std::cout << "Bad:  " << parser->Parse(badInput)  << std::endl;
    std::cout << "Good: " << parser->Parse(goodInput) << std::endl;
}

Output

Bad:  <p><strong>Some Title</strong> - List element 1 - List element 2 </p>
Good: <p><strong>Some Title</strong> </p><ul><li>List element 1</li><li>List element 2</li></ul>

Conditions

. .
Operating System: macOS 10.15.6
Compiler: Apple clang 11.0.3
Compiler flags: clang++ -std=c++17 -Imaddy/include -o maddy_test main.cpp
maddy version: 1.1.1

I don't think it is a platform issue, just filling for the sake of completeness

Description

The parser doesn't recognise the list if there is not a empty line before it. It feels a bit weird as most other parsers/viewer handles it.
I'll have a deeper look at the code and try to make a pull request.

About codeblock parser problem and solution

Minimal Code Example

static std::regex re("^(?:`){3}$");

Conditions

. .
Operating System: Win10
Compiler: VS2019
Compiler flags: C++14
maddy version: newest

Description

I found codeblock parser invalid。I had solved it with new re string “^(?:`){3}(.*)$”

static std::regex re("^(?:`){3}$"); ===>>> static std::regex re("^(?:`){3}(.*)$"); 

now it works good!

Issue with parsing

Minimal Code Example

# Heading

<a href="abc.html">Link</a>
<a href="abc.html">Link</a>
<a href="abc.html">Link</a>
<a href="abc.html">Link</a>

I want to prevent those anchor tags from being surrounded with p tags

Conditions

. .
Operating System: Ubuntu 18.04
Compiler: g++
Compiler flags: none
maddy version: 1.1.0

Description

How to prevent a specific portion of code from being rendered ?

latex support?

Can you add latex support?

inline formula: $...$
display formula: $$...$$

Don't escape the formula.

squash appveyor commits

Is it possible to squash all appveyor commits ?
The commit history is a big dirty right now..

Such tests should be done in a different branch or in a fork

Add further configuration options to disable particular parsers

I'm using Maddy to parse simple Markdown-like text and would find it useful to have more configuration options to disable particular parsers, in the same way that the Config object allows the emphasis parser to be disabled. I'd actually like to have only the parsers for bold/stong text and emphasis enabled, and disable everything else. It would be great to have some more members in the Config object to make this possible.

Vcpkg support

What are you missing in maddy?

When I seeking maddy on vcpkg, I found an "unofficial-maddy" repo and which contains the command of downloading file from this github repo. So I want to know whether you can add an official support on vcpkg, either the "unofficial" one is supported by official.

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.