-
-
Save JoshDevHub/8361cc81d5998b1aa8ab86271f1fb493 to your computer and use it in GitHub Desktop.
Example Markdown Parse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I'm reading this in from the filesystem, obviously you wouldn't do this | |
const fs = require('fs'); | |
const readFile = (path) => fs.readFileSync(path, { encoding: 'utf8' }); | |
const MARKDOWN_H3 = '###'; // all rules are delimited by h3s | |
const EARLY_SECTIONS_COUNT = 3; // early sections can be disgarded | |
const rules = readFile('./community-rules.md') | |
.split(MARKDOWN_H3) | |
.slice(EARLY_SECTIONS_COUNT); | |
const ruleObjects = rules.reduce((objects, rule) => { | |
const [titleSection, goodSection, badBehavior] = rule.split("</span>"); | |
const title = titleSection.split("\n")[0]; | |
const goodBehavior = goodSection.split("<span class=")[0]; | |
return [...objects, { title, goodBehavior, badBehavior }]; | |
}, []) | |
console.log(ruleObjects); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
title: ' Discuss topics that are safe and welcoming for everyone', | |
goodBehavior: ' Discuss topics that are relevant to our curriculum or have an off-topic channel.\n' + | |
'\n', | |
badBehavior: ' Do not discuss any unrelated topics that can be divisive or harmful, such as illegal activities, politics, religion, relationships, mental health, medical conditions, medicine, homeopathic or other home remedies, etc.\n' + | |
'\n' | |
}, | |
{ | |
title: ' Ask questions about content or projects in our curriculum', | |
goodBehavior: ' The purpose of this server is to support people when they run into issues doing our curriculum. This allows our volunteers to know the exact scope of your problem and correct any poor advice. In addition, this limited scope helps us identify areas in our curriculum that we need to improve.\n' + | |
'\n', | |
badBehavior: ' Do not ask for advice/help on homework or personal projects, even if the topic is covered by our curriculum. Instead, research other servers/communities that offer general programming help.\n' + | |
'\n' | |
}, | |
{ | |
title: ' Ask questions about the tools recommended in our curriculum', | |
goodBehavior: ' This community is run by the same volunteers who maintain the curriculum and they created this server as a way to support people when they run into issues with our recommendations.\n' + | |
'\n', | |
badBehavior: " Do not suggest tools that are outside of the curriculum's recommendations, such as using Windows, WSL, etc, because our committed volunteers are not equipped to support these additional tools. You are welcome to use them, but do not suggest them to others.\n" + | |
'\n' | |
}, | |
{ | |
title: ' Ask questions in public channels for anyone to answer', | |
goodBehavior: ' Ask questions in public channels because everyone in this community shares the responsibility to answer questions and others can learn from reading the conversation. It is unfair to expect specific people to answer your question.\n' + | |
'\n', | |
badBehavior: ' Do not send direct messages, friend requests, or ping another user without prior consent.\n' + | |
'\n' | |
}, | |
{ | |
title: ' Ask your question in only one channel', | |
goodBehavior: ' After asking your question in one channel, allow at least 30 minutes for a reply. While you are waiting, make sure that you posted in the most relevant channel, provided a detailed question, and continue trouble-shooting. It is recommended to edit your post with the results of things you have tried. If your post gets buried, you may repost your question, otherwise, you may direct people to your question in a more active channel.\n' + | |
'\n', | |
badBehavior: ' Do not post the same question in multiple channels.\n\n' | |
}, | |
{ | |
title: ' Help others by guiding them to the solution in a public 1:1 conversation', | |
goodBehavior: ' Our community values guiding a person to the solution because it empowers them with more practical skills to apply the next time they run into a problem.\n' + | |
'\n', | |
badBehavior: ' Do not provide the answer or intrude into a public 1:1 conversation with a different answer. If the guidance is incorrect, you may politely state that there might be some confusion and ask permission to help clarify the issue.\n' + | |
'\n' | |
}, | |
{ | |
title: ' Make it easy for others to help you by asking a detailed question', | |
goodBehavior: ' Ask detailed questions by following our [How to Ask Technical Questions](https://www.theodinproject.com/guides/community/how_to_ask) guide. Since your post will be fairly long, use shift + enter to add new lines between paragraphs. A detailed question should contain the following elements:\n' + | |
'\n' + | |
'- Link to the lesson/project in the curriculum\n' + | |
'- Your current code or pseudo code\n' + | |
'- Explain the issue/problem\n' + | |
'- Describe what you are expecting\n' + | |
'- Summarize what you have tried\n' + | |
'\n', | |
badBehavior: ' Avoid asking low effort questions because it puts too much responsibility on others to properly guide you to the answer. For example:\n' + | |
'\n' + | |
'- Not providing enough details or context\n' + | |
'- Asking questions that can be easily googled or not doing your own research first\n' + | |
'- Posting multiple short messages in rapid succession because they are often incomplete sentences that make it hard for others understand the full situation.\n' + | |
'\n' + | |
'**We take this rule very seriously because repeatedly asking low effort questions causes a drain on our community of volunteers.**\n' + | |
'\n' | |
}, | |
{ | |
title: ' Share resources that are relevant to our curriculum', | |
goodBehavior: ' When sharing resources that are relevant to our curriculum, add surrounding context, such as where you are in the curriculum, what exactly you found helpful, a code example, etc. Remember that our curriculum is open source, so you are encouraged to make a pull request to add it to the curriculum.\n' + | |
'\n', | |
badBehavior: ' The following resources are not relevant to our curriculum and should not be posted. If you have extraordinary circumstances that you would like to be considered, you are welcome to message ModMail for permission:\n' + | |
'\n' + | |
'- Link to a resource you created for personal or monetary gain\n' + | |
'- Request to have people fill out a survey\n' + | |
'- Link to join another server/community\n' + | |
'- Articles or blog posts on unrelated topics/languages\n' + | |
'- Fundraising or donation drives\n' + | |
'- Job posts or recruitment\n' + | |
'\n' | |
}, | |
{ | |
title: ' Report misconduct to ModMail', | |
goodBehavior: ' Use Modmail to report misconduct, private harassment by a community member, or if anyone makes you or others feel unsafe, uncomfortable, or unwelcome in our community.\n' + | |
'\n', | |
badBehavior: ' Do not correct or confront another user about their misconduct. We know you mean well, but this will often make the situation worse.\n' + | |
'\n' | |
}, | |
{ | |
title: ' Act professionally and treat everyone with respect', | |
goodBehavior: ' The culture of this community is very similar to the professional workplace messaging apps of our volunteer team. Learning how to respectfully interact with others from around the world will prepare you to interact with your future teammates.\n' + | |
'\n', | |
badBehavior: ' We have zero tolerance for disrespect. Therefore, the following behaviors will result in a ban from our server:\n' + | |
'\n' + | |
'- Bigotry, such as racism, homophobia, hate speech, etc\n' + | |
'- NSFW or other highly offensive images in posts, profile pictures, or username\n' + | |
'- Spamming multiple channels with the same or nonsensical messages (copypasta)\n' + | |
'- Disrespectful or targeted harassment, directed insults, naming & shaming\n' + | |
'- Aggressive arguments\n' + | |
'- Inciting drama, provoking/baiting other users, passive aggression\n' + | |
'- Unsolicited self-promotion\n' + | |
'- Piracy, links to pirated material, suggesting pirating intellectual property\n' + | |
'- Plagiarism\n' + | |
'- Doxxing\n' + | |
'- Trolling\n' + | |
'- Publicly arguing about receiving moderation after being asked to discuss privately through ModMail\n' + | |
'- Any other behavior deemed unacceptable and deserving of a ban by the moderation team, such as displaying a pattern of breaking our rules\n' | |
} | |
] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment