Giter Site home page Giter Site logo

Adding New Line charachter about share2fedi HOT 7 CLOSED

mpaglia0 avatar mpaglia0 commented on June 11, 2024
Adding New Line charachter

from share2fedi.

Comments (7)

kytta avatar kytta commented on June 11, 2024 1

No problem! Glad I could help you ☺️

from share2fedi.

kytta avatar kytta commented on June 11, 2024

Hello, could you provide a bit more information? What is the example text you are trying to post, and what is the toot's and Mastodon instance URL? Also, what browser and OS are you on?

I have tried it right now, and for me, it still works fine πŸ€”

from share2fedi.

mpaglia0 avatar mpaglia0 commented on June 11, 2024

I am trying to use your service through a plugin written in Python.
I use the following string (example):
f"https://toot.kytta.dev/?text={title}{LF}{url}{LF}{hashtags}"
and - before this instruction - I defined
LF = '\n'

from share2fedi.

mpaglia0 avatar mpaglia0 commented on June 11, 2024

Tested also the method
import os
and then
f"https://toot.kytta.dev/?text={title}{os.linesep}{url}{os.linesep}{hashtags}"
without success

from share2fedi.

kytta avatar kytta commented on June 11, 2024

I use the following string (example):
f"https://toot.kytta.dev/?text={title}{LF}{url}{LF}{hashtags}"
and - before this instruction - I defined
LF = '\n'

I think the problem is that your newline character is not URL encoded. For example, you can't put whitespaces in URLs, you have to replace them with %20. For a newline, that would be %0D%0A

I suggest you change your script a little bit as follows:

from urllib.parse import urlencode

query = urlencode({
    "text": f"{title}{LF}{url}{LF}{hashtags}"
})

url = f"https://toot.kytta.dev/?{query}"

from share2fedi.

kytta avatar kytta commented on June 11, 2024

Tested also the method
import os
and then
f"https://toot.kytta.dev/?text={title}{os.linesep}{url}{os.linesep}{hashtags}"
without success

And I wouldn't use os.linesep in this case. os.linesep is meant for files stored on different filesystems in different OSes: on Windows, it's CRLF, but on Unix-based OSes, it's LF. On the Web, however, it's the same everywhere, and you can just use \n

from share2fedi.

mpaglia0 avatar mpaglia0 commented on June 11, 2024

Works perfectly!
The problem was actually my poor Python knowledge.
Please apologize...

from share2fedi.

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.