Export topic as markdown

I found this UI: Topic and Category Export/Import but that does not cover what I was thinking about:

  • A means to export an entire public or DM topic as a single markdown document where the export action is UI-accessible to all the participants in said topic.

And maybe (but for me not required) to have this feature available for anyone on public topics.


I interact with many Discourse forums publicly and DM’ingly and have a need to archive discussions there in a personal markdown-based knowledge base. This is not only very time-consuming, but I can’t get the raw markdown of other people’s posts in forums where I’m not mod or admin (logically), so I have to recreate it manually.

「いいね!」 7

You can already access the raw markdown to topics:
Https://meta.discourse.org/raw/152185

「いいね!」 2

Thanks, that would be so cool. But it only returns the first post in the topic and not the entire conversation thread.

Edit: More doable, by iterating over each post in the thread in raw mode, but for a thread with 60 posts still a lot of work. Furthermore it contains only the body of the post and there is no information on who posted, and when.

You can use the print function on a topic and save the output to a pdf. It is not markdown but it is easy!

「いいね!」 1

Thank you, yes, I sometimes use that, but the content becomes ‘locked in’. It does not fit well with my knowledge base (create cross-links, etc.). Markdown is so simple and easy to work with, that I select all my tools around it. It is a great timesaver if you can just move MD snippets around all over the place.

「いいね!」 2

I was just asked that question yesterday. Are you referring to the print function of the browser? Or is there a Discourse feature to print the entire topic thread that I am not seeing?

https://meta.discourse.org/t/print-long-topic-to-pdf-redux-again/44639/37?u=falco

「いいね!」 2

Funny, I too would like something like this! So just another vote of support, I guess…

こんにちは。

この機能が非常に重要だと私も思うので、ここにアカウントを作成しました。

現在、コードブロックを含むスレッドをPDFに印刷すると、折り返しや拡張が行われず、内容が切り取られてしまうため、うまく機能しません。

Discourseからコンテンツを、例えばアーカイブ目的で取得するための、信頼性が高く比較的簡単な方法が本当に重要だと思います。

もう1つの考慮事項:最近閉鎖されたメーリングリストから多くのユーザーを統合したフォーラムに参加していますが、メーリングリストをアクティブに保つか、フォーラムに完全に切り替えるかの移行に関する議論の中で、目の不自由なメンバーが、テキストベースのブラウザのサポートがないためフォーラムに参加できないだろうと述べました。適切な生のモードで、著者名とすべてのスレッドを含めることで、より包括的なものになると思います。

「いいね!」 2

Let’s see. I’ll include a code block here with a fair bit of code and see what it looks like in print:

import java.util.Scanner;

/**
 * Game of AceyDucey
 * <p>
 * Based on the Basic game of AceyDucey here
 * https://github.com/coding-horror/basic-computer-games/blob/main/01%20Acey%20Ducey/aceyducey.bas
 * Note:  The idea was to create a version of the 1970's Basic game in Java, without introducing
 * new features - no additional text, error checking, etc has been added.
 */
public class AceyDucey {

    // Current amount of players cash
    private int playerAmount;

    // First drawn dealer card
    private Card firstCard;

    // Second drawn dealer card
    private Card secondCard;

    // Players drawn card
    private Card playersCard;

    // User to display game intro/instructions
    private boolean firstTimePlaying = true;

    // game state to determine if game over
    private boolean gameOver = false;

    // Used for keyboard input
    private final Scanner kbScanner;

    // Constant value for cards from a deck - 2 lowest, 14 (Ace) highest
    public static final int LOW_CARD_RANGE = 2;
    public static final int HIGH_CARD_RANGE = 14;

    public AceyDucey() {
        // Initialise players cash
        playerAmount = 100;

        // Initialise kb scanner
        kbScanner = new Scanner(System.in);
    }

    // Play again method - public method called from class invoking game
    // If player enters YES then the game can be played again (true returned)
    // otherwise not (false)
    public boolean playAgain() {
        System.out.println();
        System.out.println("SORRY, FRIEND, BUT YOU BLEW YOUR WAD.");
        System.out.println();
        System.out.println();
        System.out.print("TRY AGAIN (YES OR NO) ");
        String playAgain = kbScanner.next().toUpperCase();
        System.out.println();
        System.out.println();
        if (playAgain.equals("YES")) {
            return true;
        } else {
            System.out.println("O.K., HOPE YOU HAD FUN!");
            return false;
        }
    }

    // game loop method

    public void play() {

        // Keep playing hands until player runs out of cash
        do {
            if (firstTimePlaying) {
                intro();
                firstTimePlaying = false;
            }
            displayBalance();
            drawCards();
            displayCards();
            int betAmount = getBet();
            playersCard = randomCard();
            displayPlayerCard();
            if (playerWon()) {
                System.out.println("YOU WIN!!");
                playerAmount += betAmount;
            } else {
                System.out.println("SORRY, YOU LOSE");
                playerAmount -= betAmount;
                // Player run out of money?
                if (playerAmount <= 0) {
                    gameOver = true;
                }
            }

        } while (!gameOver); // Keep playing until player runs out of cash
    }

    // Method to determine if player won (true returned) or lost (false returned)
    // to win a players card has to be in the range of the first and second dealer
    // drawn cards inclusive of first and second cards.
    private boolean playerWon() {
        // winner
        return (playersCard.getValue() >= firstCard.getValue())
                && playersCard.getValue() <= secondCard.getValue();

    }

    private void displayPlayerCard() {
        System.out.println(playersCard.getName());
    }

    // Get the players bet, and return the amount
    // 0 is considered a valid bet, but better more than the player has available is not
    // method will loop until a valid bet is entered.
    private int getBet() {
        boolean validBet = false;
        int amount;
        do {
            System.out.print("WHAT IS YOUR BET ");
            amount = kbScanner.nextInt();
            if (amount == 0) {
                System.out.println("CHICKEN!!");
                validBet = true;
            } else if (amount > playerAmount) {
                System.out.println("SORRY, MY FRIEND, BUT YOU BET TOO MUCH.");
                System.out.println("YOU HAVE ONLY " + playerAmount + " DOLLARS TO BET.");
            } else {
                validBet = true;
            }
        } while (!validBet);

        return amount;
    }

    private void displayBalance() {
        System.out.println("YOU NOW HAVE " + playerAmount + " DOLLARS.");
    }

    private void displayCards() {
        System.out.println("HERE ARE YOUR NEXT TWO CARDS: ");
        System.out.println(firstCard.getName());
        System.out.println(secondCard.getName());
    }

    // Draw two dealer cards, and save them for later use.
    // ensure that the first card is a smaller value card than the second one
    private void drawCards() {

        do {
            firstCard = randomCard();
            secondCard = randomCard();
        } while (firstCard.getValue() >= secondCard.getValue());
    }

    // Creates a random card
    private Card randomCard() {
        return new Card((int) (Math.random()
                * (HIGH_CARD_RANGE - LOW_CARD_RANGE + 1) + LOW_CARD_RANGE));
    }

    public void intro() {
        System.out.println("ACEY DUCEY CARD GAME");
        System.out.println("CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY");
        System.out.println();
        System.out.println();
        System.out.println("ACEY-DUCEY IS PLAYED IN THE FOLLOWING MANNER");
        System.out.println("THE DEALER (COMPUTER) DEALS TWO CARDS FACE UP");
        System.out.println("YOU HAVE AN OPTION TO BET OR NOT BET DEPENDING");
        System.out.println("ON WHETHER OR NOT YOU FEEL THE CARD WILL HAVE");
        System.out.println("A VALUE BETWEEN THE FIRST TWO.");
        System.out.println("IF YOU DO NOT WANT TO BET, INPUT: 0");
    }
}

Note that we have fairly complete accessibility support, so I’d be interested to hear specifically what is not working for your blind user @thresholdpeople .

Also the above code block looks fine in the printed version to me. I just pressed “print” in Chrome then “save as PDF” to generate a PDF version of this very topic:

Export topic as markdown - feature - Discourse Meta.pdf (249.9 KB)

I am not seeing a problem. Please point to specific areas in the PDF that aren’t correct if you do see a problem. Thanks!

これについて調べていただきありがとうございます。

Vivaldi を使用していますが、Chrome も使用しており、さまざまなコンピューターで、ブラウザーの設定が同期されていないものも含めて使用しましたが、コード ブロックを印刷すると、次の場所で切り取られます。

     // Players drawn card
     private Card playersCard;

これは、コード フレーム内で下にスクロールして詳細を確認する必要があるため、インラインで投稿を表示する際に表示できるすべてです。私のバージョンを投稿できればよいのですが、ファイルをアップロードするには投稿数が足りません。しかし、お察しの通りです。

印刷されたバージョンは確かに見栄えが良いですが、なぜ違うのかはよくわかりませんが、完璧ではありません。コード行は折り返されず、切り取られ、すべてのページに左下に浮いている青い長方形があり、これも一部のテキストを隠しています。残念ながら、その状態では実際には使用できません。

SuperCollider フォーラムの誰かが、ブラウザーのインスペクターに、またはブラウザー プラグインを使用する際に (現在、Chrome 拡張機能 Stylish を使用しており、そのフォーラムにアクセスすると自動的に追加されます) 次の CSS ブロックを貼り付けるという解決策を提供しました。

pre code {
    white-space: 	pre-wrap;
    max-height: 	none;
    background: 	#fafafa;
}

これを使用すると、印刷が正常に機能します。ブラウザー拡張機能を使用すると、何かを保存したいときに毎回追加する必要がなくなり、実際の修正となります。そうでなければ、手間がかかりすぎます。

それでも、スレッドをアーカイブする簡単な方法があればよいのにと思います。あるいは、追加の手順が必要なかった方法があればよいのにと思います。

特に、ほとんどの機能はすでに存在するためです。投稿をそのまま表示するか、印刷できるかのいずれかです。しかし、スレッド全体をそのまま表示することはできず、単一の投稿のみが表示され、印刷はうまく機能しません。

とはいえ、ブックマークは素晴らしいフォーラム機能であり、常に使用していますが、すべてが discourse 内に収まっています。

「いいね!」 1

生の@falcoとしてトピック全体を返すルートを追加できます。これは役立つかもしれませんが、メガトピックには注意が必要です。

個々の投稿については、すでにこれがあります。

https://meta.discourse.org/raw/152185/12

「いいね!」 3

それは確かに可能ですが、かなりニッチなユースケースです。

フォーマットは次のようになります。

ユーザー名 | タイムスタンプ | 投稿番号

投稿本文

---

ユーザー名 | タイムスタンプ | 投稿番号

投稿本文

---

ユーザー名 | タイムスタンプ | 投稿番号

投稿本文

「いいね!」 2

はい、私はそれを支持します。投稿用の /raw/ ルートがあるのに、トピック用のルートがないのはなぜですか?

「いいね!」 2

現在、ルート https://meta.discourse.org/raw/152185 は OP のみを返します。そのルートの動作を変更してもよろしいでしょうか? OP のみを取得するには、ユーザーは明示的に https://meta.discourse.org/raw/152185/1 を呼び出す必要があります。

「いいね!」 2

お任せします。

「いいね!」 2

これが現在公開されています: https://meta.discourse.org/raw/152185

これが意図したものであれば、お知らせください @here

「いいね!」 8

気に入りました!私には良く見えます!:heart_eyes:

「いいね!」 3

これは本当に素晴らしいです。ありがとうございます :pray:

「いいね!」 3

ありがとうございます!そして、もっとキャラクターを!

「いいね!」 2