GithubHelp home page GithubHelp logo

Comments (7)

jamalex avatar jamalex commented on July 28, 2024 1

Ok, cool, if that resonates, then I'll go with that, along with disabling dash-conversion in the standard markdown conversion.

from notion-py.

Cobertos avatar Cobertos commented on July 28, 2024

I'm having issues with this while trying to upload yaml documents of the format

title: Test
tags:
  - Video Game Art
  - Blender
  - Modelling
  - Render
  - Cycles
  - Quackventures
permalink: test
id: 59f834a1fe4ed100192567da
updated: '2018-06-14T07:20:33.000Z'
date: 2016-02-08 03:59:20

cause issues. The yaml array gets parsed as Markdown and each line becomes separated by a new line and loses the array prefix -

from notion-py.

Cobertos avatar Cobertos commented on July 28, 2024

After further investigation, you can monkey-patch markdown=False with

from notion.block import CodeBlock
from notion.maps import property_map
CodeBlock.title = property_map('title', markdown=False)

but the problem is the CodeBlock actually supports Markdown in it (?!). So you'll get CodeBlock's from the backend looking like

[['titl'], ['e: Bobskater mmmmA Pytho', [['b']]], ['n obfuscation Library\ntags:\nmmmm'], ['Python\nmmmmpython3\nmmmmbobskater\nmmmmobfuscatio', [['s']]], ['n\nmmm'], ['mminify\nmmmmast\nmmmmabs', [['h', 'red']]], ["tract syntax tree\nmmmmregex\npermalink: bobskater-a-python-obfuscation-library\nid: 5adfe539190df80022801a50\nupdated: '2018-08-30T01:31:57.000Z'\ndate: 2018-05-04 21:11:00"]]

If you need a quick and dirty fix and don't need to support Markdown in your code blocks. Use the above monkey patch and then make sure whenever you set title on a CodeBlock, you're actually passing in [["your code here"]] to satisfy Notion.so's format

from notion-py.

jamalex avatar jamalex commented on July 28, 2024

Good catch! It actually looks as if this isn't something specific to CodeBlock, as the same thing happens with a basic block when multiple lines prefixed with - are set. It's just less common outside of a CodeBlock. It seems to be a problem with the way I'm doing "Markdown to Notion" conversion. Or rather, I think it may just be an inherently tricky/ambiguous case, where it doesn't have a good way to tell, when going from Markdown to Notion format, when to interpret literally and when to interpret as Markdown annotations.

the problem is the CodeBlock actually supports Markdown in it (?!)

Exactly. This would all be much easier if we could assume there's no styling within a code block. But as you've observed, in Notion you can select text within a code block and, for example, make it bold.

I'm thinking to add a parallel title_plaintext property that strips (and adds) the [[ ]], but doesn't do any markdown conversion. I'll do a quick pass on that now, but let me know if you have any other suggestions.

from notion-py.

jamalex avatar jamalex commented on July 28, 2024

After playing with this a bit more, a couple of observations:

  1. The same problem happens with other types of Markdown in CodeBlocks (e.g. __stuff_like_this__ triggers bolding). This doesn't cause issues in the same way for other block types because they automatically convert __X__ and *X* on the fly into formatting as you type. This auto-styling doesn't happen in CodeBlocks.
  2. I can't actually think of a case where dashes can be used for bullets within Notion (other than as a keyboard shortcut for converting the entire block into a BulletedListBlock). So there's no reason we should be touching dashes in the conversion process.

So... if it weren't for 1), then fixing 2) by ignoring dashes would be enough. I'm thinking to ignore dashes, but also just turn off markdown conversion completely for CodeBlock as suggested. This means that modifying an existing CodeBlock that had formatting internally will clear the formatting, but this seems like an uncommon scenario.

from notion-py.

Cobertos avatar Cobertos commented on July 28, 2024

I really like the idea of title_plaintext. It preserves the current API and gives the user the ability to choose which one to use. Kind of like .innerHTML and .textContent in a way...

from notion-py.

jamalex avatar jamalex commented on July 28, 2024

Ok, done! Will be in the upcoming release: #84

from notion-py.

Related Issues (20)

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.